aspose file tools*
The moose likes Web Services and the fly likes How to get SOAP response as XML in Client Struts or Servlet. ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to get SOAP response as XML in Client Struts or Servlet. ? " Watch "How to get SOAP response as XML in Client Struts or Servlet. ? " New topic
Author

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

Arpit Goel
Greenhorn

Joined: Nov 03, 2008
Posts: 9
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.


Arpit Goel
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
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 ]

Ping & DNS - my free Android networking tools app
Arpit Goel
Greenhorn

Joined: Nov 03, 2008
Posts: 9
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

Joined: Jul 21, 2004
Posts: 83
Won't Apache SOAP will help you in this??


SCJP,SCWCD,SCBCD,SCDJWS1.4, SCDJWS1.5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
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

Joined: Jul 21, 2004
Posts: 83
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

Joined: Jul 21, 2004
Posts: 83
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?
 
 
subject: How to get SOAP response as XML in Client Struts or Servlet. ?