• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SOAP web service

 
Arjun Shastry
Ranch Hand
Posts: 1899
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1899
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The client code uses a different endpoint URL than the service code; that's why the service is not found.
 
Arjun Shastry
Ranch Hand
Posts: 1899
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic