[java] Java Webservice Client (Best way)

I have a third party WSDL, I need to write code in Java for a web service client to invoke the operations in the third party WSDL. Right now, I have generated the client stub using the WSDL2JAVA tool from Axis and used the XMLbeans for data binding.

  1. What is the best approach to do this JAVA?
  2. I read about SAAJ, looks like that will be more granular level of approach?
  3. Is there any other way than using the WSDL2Java tool, to generate the code. Maybe wsimport in another option. What are the pros and cons?
  4. Can someone send the links for some good tutorials on these topics?
  5. What are the options we need to use while generating the code using the WSDL2Java?

I used some of the basic things initially. Now I have these options

C:\axis2-1.5.1\bin>wsdl2java -uri  mywsdlurl  -o client -p somepackage -d xmlbeans -s -t -ssi

This question is related to java jax-ws axis2 wsdl2java webservice-client

The answer is


Some ideas in the following answer:

Steps in creating a web service using Axis2 - The client code

Gives an example of a Groovy client invoking the ADB classes generated from the WSDL.

There are lots of web service frameworks out there...


You can find some resources related to developing web services client using Apache axis2 here.

http://today.java.net/pub/a/today/2006/12/13/invoking-web-services-using-apache-axis2.html

Below posts gives good explanations about developing web services using Apache axis2.

http://www.ibm.com/developerworks/opensource/library/ws-webaxis1/

http://wso2.org/library/136


What is the best approach to do this JAVA?

I would personally NOT use Axis 2, even for client side development only. Here is why I stay away from it:

  1. I don't like its architecture and hate its counter productive deployment model.
  2. I find it to be low quality project.
  3. I don't like its performances (see this benchmark against JAX-WS RI).
  4. It's always a nightmare to setup dependencies (I use Maven and I always have to fight with the gazillion of dependencies) (see #2)
  5. Axis sucked big time and Axis2 isn't better. No, this is not a personal opinion, there is a consensus.
  6. I suffered once, never again.

The only reason Axis is still around is IMO because it's used in Eclipse since ages. Thanks god, this has been fixed in Eclipse Helios and I hope Axis2 will finally die. There are just much better stacks.

I read about SAAJ, looks like that will be more granular level of approach?

To do what?

Is there any other way than using the WSDL2Java tool, to generate the code. Maybe wsimport in another option. What are the pros and cons?

Yes! Prefer a JAX-WS stack like CXF or JAX-WS RI (you might also read about Metro, Metro = JAX-WS RI + WSIT), they are just more elegant, simpler, easier to use. In your case, I would just use JAX-WS RI which is included in Java 6 and thus wsimport.

Can someone send the links for some good tutorials on these topics?

That's another pro, there are plenty of (good quality) tutorials for JAX-WS, see for example:

What are the options we need to use while generating the code using the WSDL2Java?

No options, use wsimport :)

See also

Related questions


I have had good success using Spring WS for the client end of a web service app - see http://static.springsource.org/spring-ws/sites/1.5/reference/html/client.html

My project uses a combination of:

  • XMLBeans (generated from a simple Maven job using the xmlbeans-maven-plugin)

  • Spring WS - using marshalSendAndReceive() reduces the code down to one line for sending and receiving

  • some Dozer - mapping the complex XMLBeans to simple beans for the client GUI


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to jax-ws

What is the difference between JAX-RS and JAX-WS? How to do a SOAP Web Service call from Java class? How to programmatically set the SSLContext of a JAX-WS client? What is the difference between Document style and RPC style communication? Java Web Service client basic authentication How to add soap header in java JAX-WS client : what's the correct path to access the local WSDL? Java Webservice Client (Best way) How to change webservice url endpoint? JAX-WS - Adding SOAP Headers

Examples related to axis2

ORA-12516, TNS:listener could not find available handler The endpoint reference (EPR) for the Operation not found is Content is not allowed in Prolog SAXParserException Java Webservice Client (Best way) How do you Change a Package's Log Level using Log4j? Difference between Apache CXF and Axis

Examples related to wsdl2java

Importing xsd into wsdl How to avoid the need to specify the WSDL location in a CXF or JAX-WS generated webservice client? Java Webservice Client (Best way) Access restriction on class due to restriction on required library rt.jar?

Examples related to webservice-client

WebService Client Generation Error with JDK8 javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake during web service communicaiton Client to send SOAP request and receive response Content is not allowed in Prolog SAXParserException Java Webservice Client (Best way)