Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get SOAP response as XML in Client Struts or Servlet. ?

 
Arpit Goel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I am using JAX-RPC. Currently my client (Struts Action) get Web Service response as JAVA object. But I need that response ax XML.

I am able to retrive SOAP request / response as XML directly by writing Handlers for Server and Client. Handler are triggered on Req and response and can do some processing on SOAP messages.

But I need that XML SOAP Response in my Struts Action Class or Servlet. How can I access that ? Please advice.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how to do this with JAX-RPC, but if you need to work with the SOAP on such a low level you may be better off using SAAJ instead. It's easy to get an javax.xml.transform.Source object from the SOAP response, which you then can use as you see fit.
[ November 06, 2008: Message edited by: Ulf Dittmer ]
 
Arpit Goel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for response.

Issue is like this that If I add/remove attributes in WSDL for some client, I need to have all client with modified Java Object Code for Deserialiation to avoid any deserialization error.

So to avoid that I think I need to get web service response as direct XML ( Not Attachment ) so different client can customize the response xml using xml binding for their use. Currently my implementation uses marshaling / unmarshalling of objects so I get data as JAVA Data Objects (DTOs ). How can I access SOAP body contents in client Web App ( Not in Handlers ) in JAX-RPC without changing my current implementaion to SAAJ.

Or is there any way we can define whether client can skip deserialization of attribute if that attribute is not availablbe in client Side skelton classes.
 
Amit G Piplani
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won't Apache SOAP will help you in this??
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apache SOAP has been obsolete for years; don't use it. (It's not even listed on ws.apache.org any more.)
 
Amit G Piplani
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i agree SOAP is obsolete, sorry for posting that as recommendation...

Although JAX-WS provides Dispatch and Provider functionality to operate at the XML message level.
 
Amit G Piplani
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But again JAX-WS is used with JEE 1.5 onwards, and its not a solution if you are using J2EE 1.4.
Although it looks like using SAAJ and Message Handler can work it out

Ulf/Arpit, will web service versioning help in this case? As per Arpit's requirement, he is willing to change some attributes in WSDL(mostly in Schema), will web service versioning help in this case?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic