• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling Web Service Method using SAAJ

 
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends,

I have an XML document(DOM object) which should be sent to the Web Service from a java client.
I created the DOM by iterating through the JDBC ResultSet. The DOM when converted to String will display the full XML data.

I developed the following code.


I need to send the Document as SOAP message.
TestService.java is a Web Service class from which i created the WSDL. In this class, there is a method processRequest() which takes SOAPMessage type as argument.


Follwing is the WSDL generated by Axis:



My problem is, how to call this method from the java client. In Axis, we can do a setOperationName("methodName") to call a particular web service method. But when using SAAJ, how to call the particular method of the webservice since there is only provision (that i know) to send only the webservice endpoint URL.

i am using JDK 6 and Tomcat 5.5.27 with Eclipse Galileo as the editor.

Kindly provide your help.

Following is the exception i get:


Thanks,
Vijay
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
First, you know that SOAP encoding is discouraged by the WS-I Basic Profile, right? In your code you set the encoding style to SOAP encoding, despite the fact that in the WSDL it is Literal.

You'll make your life easier and your code more clear if you, instead of writing code to create SOAP messages use the following approach:
- From the WSDL, generate JAXB bean classes.
- After having queried the database, create the appropriate JAXB beans and insert data.
- Let JAXB marshall the data to XML (optional step, see next step).
- Insert the XML data into a SOAP message or use a JAXBSource when sending the message.

Regarding the operation name:
You have a Document/Literal style web service. This is not RPC. You send the web service a chunk of XML and, depending on the data in the XML, it selects the way to process the request. I recommend reading some about Document style messaging. Here is one article: http://www.ibm.com/developerworks/webservices/library/ws-docstyle.html
Best wishes!
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic