Iofacture
Iofacture

Reputation: 685

Java XML creation from XSD and SOAP services with Eclipse

So I have some general questions and I am not sure where to start. I have a web project that is contained within a project EAR. I am using Eclipse. I have the need to do the following:

  1. On a form submission take the bean values and map them to an XML file using an XSD
  2. Will need a completely separate SOAP based Web Service Client

I mention these things together because as im looking into it I see a lot about JAXB. I was going to install some web service developer tools but stopped and realized I could probably use the tools that come with eclipse project for item #2 to accomplish item #1. The web project could reference the client and use the xml tools there to generate the needed XML.

I have never done any XML conversion or SOAP webservices with java before. Where do I start?

Upvotes: 0

Views: 3401

Answers (1)

Iofacture
Iofacture

Reputation: 685

Well in case anyone was wondering. After quite a lot of research here is the answer:

  1. To accomplish this, simply place the XSD files in a folder, highlight the schema file containing the root element you need, and right click->new->other->generate JAXB classes. That will generate the stub classes you need into a folder and the 'factory' object will allow you to create the in-java XML references you need to map your values to XML. You then call the JAXB tools to 'marshal' the XML to a given output stream. A good tutorial on this can be found here: http://www.javacodegeeks.com/2011/02/jaxb-generate-xml-xsd.html

  2. This can be done a number of ways. Easiest one is to create a new dynamic web project. If you already have a WSDL file you can simply let eclipse generate a web service client for you. Right click on the WSDL file after importing it into the web project, select new->other->web service client.

Accomplishing these two tasks are un-related. JAXB is used in the creation of the web services, however this is a standard library that should come in the eclipse web tools. I believe this is standard in the 'java ee mars' version of eclipse.

So there you have it, folks.

Upvotes: 1

Related Questions