aspose file tools*
The moose likes Web Services and the fly likes SOAP web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "SOAP web service" Watch "SOAP web service" New topic
Author

SOAP web service

Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1874
Hi,
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?
regards


MH
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42930
    
  68
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.
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1874
Thanks.

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
" error.
Is some configuration pending from client side?
regards
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42930
    
  68
The client code uses a different endpoint URL than the service code; that's why the service is not found.
Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1874
Thanks again. I changed the end point URL to http://localhost:8089/WebServiceExample/circlefunctions
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 -


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42930
    
  68
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.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42930
    
  68
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SOAP web service