As per Sun site, I followed http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/ which explains about creating web service in JDK 1.6 .Author says one can use inbuilt HTTP server. So snippet of my code is like this:
I followed the instructions such as running wsgen . So service is working fine.
Question is about writing the client. Can I use SAAJ API to invoke this web service? or do I need AXIS etc to call webservice when message is of type SOAP?
I am trying to write client using SAAJ to access the above service. Snippet of code is like this:
I am getting "com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (404Not Found
SEVERE: SAAJ0008: Bad Response; Not Found
Is some configuration pending from client side?
for bodyName I am assigning the value-
The error thrown now is Exception in thread "main" java.util.NoSuchElementException at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl$3.next(ElementImpl.java:764)
I can see the entire WSDL in browser. Part of it is -
java.util.Iterator iterator = responseBody.getChildElements(bodyName);
SOAPBodyElement bodyElement1 = (SOAPBodyElement)iterator.next();
This looks dangerous. you should never call iterator.next() without a preceding iterator.hasNext() call. As long as you are debugging, you may want to print out the entire response so that you know what gets returned. Or the client could access the service through something like tcpmon or SOAPUI, so that you have a nice visual representation of what's sent over the wire.
Ulf Dittmer wrote:You can use either the SAAJ or JAX-WS API to invoke a WS. Axis has implementations of both those APIs, so you can use it, but you certainly don't need to use it - any other SOAP stack that implements SAAJ would be fine, too.
In fact, you do not need a separate SOAP stack - the JavaSE 6 JDK/JRE includes SAAJ, JAXB etc. so it is possible to develop SOAP web service clients using only Java SE nowadays.
In fact, you do not need any SOAP stack - the JavaSE 6 JDK/JRE includes SAAJ, JAXB etc. so it is possible to develop SOAP web service clients using only Java SE nowadays.
In other words, JSE 6 includes a SOAP stack.
The problem with relying on that is that JSE is updated less frequently than most of the constituent WS libraries. So the latest JSE 6 version generally contains versions of JAXB and JAX-WS that are no longer current, so you're missing out on the latest features and bug fixes.