new to web service. when developing a web service application, usually how do we come up with a wsdl file ? do we usually first write a java code then convert it to wsdl using tool or what ? does it make sense to create a wsdl first without using any java code ? -- assuming I am using java lang for WS.
I remember when I started looking at SOAP web services and WSDLs. At that time, I thought WSDLs were slightly frightening and difficult to grasp.
Despite the experience I have gained, I still do not sit down and write a WSDL document from scratch, so I am going to suggest a slightly more convenient approach to WSDL-first web service development. I call this method "WSDL first with Some Java in the Beginning".
- Write a Java class representing the endpoint implementation class, but that only contains empty methods, that is, methods with no code (except for perhaps returning null or zero values as the result of the methods).
This class is to be annotated with all the appropriate web service annotations.
- If any bean classes are needed to pass information to, or return information from, methods in the class in the previous step then implement these.
- Use wsgen to generate a WSDL document from the Java class in the previous step.
- Manually edit the generated WSDL document and customize it as desired.
- Use the WS-I Basic Profile tool to verify that the WSDL complies with the WS-I Basic Profile.
This tool can be downloaded freely from: http://www.ws-i.org/deliverables/workinggroup.aspx?wg=testingtools - Delete all the Java code written in the first two steps.
- Use wsimport to generate server side artifacts from the WSDL.
- Fill in the implementation of the different methods in the endpoint implementation class generated in the previous step.
- Use wsimport to generate client side artifacts from the WSDL.
- Implement a client using the artifacts generated in the previous step.
Joined: Mar 28, 2006
Thanks Ivan. What do I need to install to get this "wsimport" tool ?
Joined: Oct 04, 2006
Both wsimport and wsgen are part of the standard JDK as per version 1.6, so if you have it installed, then no additional installs are needed.
They are also present in GlassFish, in the bin directory in the installation directory.
ben oliver wrote:new to web service. when developing a web service application, usually how do we come up with a wsdl file ? do we usually first write a java code then convert it to wsdl using tool or what ? does it make sense to create a wsdl first without using any java code ? -- assuming I am using java lang for WS.
It's a big question. Quite often it's referred to as Top Down or Bottom up approach. For example, in WebSphere, please look at sections 17 (JAXB - Top down) and 21 (JAXB - Bottom-up).