aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes How can we use JAXB to marshall the whole SOAP request/response ? 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 » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "How can we use JAXB to marshall the whole SOAP request/response ?" Watch "How can we use JAXB to marshall the whole SOAP request/response ?" New topic
Author

How can we use JAXB to marshall the whole SOAP request/response ?

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 519
    
    2

Hi All,

We know that JAX-WS runtime would handle the marshalling of entire SOAP request and response for us. But should we want to marshall the entire SOAP request including Envelope, Header and Body how do we do that. I know, we can do the unmarshalling for Body entries as we may know the xsd and we can generate the binding classes. But In order to unmarshall the entire SOAP message do we need to create binding objects for each of the schemas for the namespace http://schemas.xmlsoap.org/soap/envelope and any other schemas associated with header entries etc.

I see an example, where SOAPMessage is accessed using Provider<SOAPMessage> but this is not usin JAXB I believe. So, is there any way, JAXB can be used to access the entire SOAPMessage, instead of just the Payload. Any example would be helpful.


Regards
KumarRaja

Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
You can use SAAJ to (un)marshall SOAP Request and response. Eventually in handlers, that's what is used. I don't think we can use JAXB to marshall/unmarshall SOAP requests and response to manipulate headers if needed and attach attachments.

In a webservice the XSD schema is not directly exposed, it is inside <wsdl:types> so even JAXB is not directly used as-is by JAX-WS.

I am a fellow aspirant for this certification so I may be wrong here. In which case veterans like Ivan can correct me here.


Kamal Tripathi
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
I absolutely agree with Kamal as SAAJ was designed to handle the entire message and produce a DOM like tree.

Regards,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 519
    
    2

Well I too agree that SAAJ is meant for that low level handling of XML directly and that is what actually shown in the example which I referred for Provider<SOAPMessage>. But why not JAXB. I may not agree that xsd is not accessible, we can very well get the xsd or may be we can request it from the service providers and they should be able to provide that which we can use for generating the bindings for SOAP body entries.

But xsd for entire SOAP message is universally accessible, I do not see any problem in acquiring the XSD for SOAP envelope. But in that case, why can't we use JAXB to bind them. I have to admit that I had not tried this by myself, but just curious if anybody had done this before.

I mean, what could be a strong reason for not using JAXB to bind the entire SOAP message, if we have access to all the required xsd. Is this because, SAAJ is already available for such purposes or is there any other issues involved.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I see nothing that would stop you from using JAXB to create entire SOAP messages.
You may need to craft an XML schema describing your SOAP message and its contents, instead of being able to use the existing SOAP XML schema - I have not tried this myself.
After all, there is nothing special about a SOAP message - it is plain XML.

A reason for separating SOAP messages and its contents is that it is two different things with different functions - an envelope and a letter.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 519
    
    2

Thanks All.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can we use JAXB to marshall the whole SOAP request/response ?