aspose file tools*
The moose likes Web Services and the fly likes Help with SAAJ and SOAP 1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Help with SAAJ and SOAP 1.2" Watch "Help with SAAJ and SOAP 1.2" New topic
Author

Help with SAAJ and SOAP 1.2

David Yu
Greenhorn

Joined: Oct 28, 2006
Posts: 24
Hi everyone,

I am trying to set up a web service that sends out SOAP 1.2 requests and processes SOAP 1.2 responses. To minimize the complexity of the application, I decided to use Java SAAJ v1.3 from the JWSDP v2.0 developer kit. Using SAAJ, I can send out and receive SOAP messages without Apache Tomcat or Apache Axis.

SAAJ 1.3 is supposed to support both SOAP 1.1 and 1.2 messages. Instead of constructing the SOAP request message by using the various "add" functions. I constructed the SOAP message beforehand and pass it as an argument to the SoapPart.

StreamSource prepSoapMsg = new StreamSource(new FileInputStream("nameOfSOAPRequest.msg"));
soapPart.setContent(prepSoapMsg);

After sending the SOAP message, I am getting a SOAP response. However, how can I tell if it is a SOAP 1.2 response?

It looks like a SOAP 1.1 response, b/c my request has tag names of

<soap12:Envelope

but response has tag names of

<soap:Envelope

Please advise. If I cannot construct SOAP 1.2 messages using SAAJ, what is the simplest alternative?
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Distinguishing SOAP 1.1 (xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/")


versus SOAP 1.2 (xmlns:soap="http://www.w3.org/2003/05/soap-envelope")


It's all in the namespace not the prefix that is used to represent the namespace.
[ September 04, 2007: Message edited by: Peer Reynders ]
David Yu
Greenhorn

Joined: Oct 28, 2006
Posts: 24
Hi Peer,

Thanks for the reply. However I need a bit more clarification. So if I send a SOAP request with xmlns:soap="http://www.w3.org/2003/05/soap-envelope" and receive a response with xmlns:soap="http://www.w3.org/2003/05/soap-envelope", that means I have a SOAP 1.2 reply?

The part that confuses me most is that according to the web service specification, if I send a soap 1.2 request like the one below:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetJpegQuery xmlns="http://skyserver.sdss.org/">
<ra_>double</ra_>
<dec_>double</dec_>
<scale_>double</scale_>
<width_>int</width_>
<height_>int</height_>
<opt_>string</opt_>
<query_>string</query_>
</GetJpegQuery>
</soap12:Body>
</soap12:Envelope>

I should get a SOAP response similar to

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<JpegQueryResponse xmlns="http://skyserver.sdss.org/">
<ra_>123.45</ra_>
</GetJpegQueryResponse>
</soap12:Body>
</soap12:Envelope>

However, my response message is <soap xxx> instead of <soap12 xxx> although I do have the same namespace.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by David Yu:
So if I send a SOAP request with xmlns:soap="http://www.w3.org/2003/05/soap-envelope" and receive a response with xmlns:soap="http://www.w3.org/2003/05/soap-envelope", that means I have a SOAP 1.2 reply?


Correct, however the prefix chosen is somewhat arbitrary, so you might see XML Namespace declarations like
  • xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  • xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
  • xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
  • xmlns:xyz="http://www.w3.org/2003/05/soap-envelope"
  • etc.


  • SOAP uses qualified names. So if there is a namespace declaration of xmlns:soap="http://www.w3.org/2003/05/soap-envelope" then <soap:envelope> is the representation of the <{http://www.w3.org/2003/05/soap-envelope}envelope> tag.

    If you see a declaration of xmlns="http://www.w3.org/2003/05/soap-envelope" then "http://www.w3.org/2003/05/soap-envelope" is your default namespace. In this case <envelope> is the representation of the <{http://www.w3.org/2003/05/soap-envelope}envelope> tag.

    However, my response message is <soap xxx> instead of <soap12 xxx> although I do have the same namespace.

    The actual prefix used is irrelevant - what has to match is the namespace that is associated with the prefix.

    Ronald Bourret: XML Namespaces FAQ
    James Clark: XML Namespaces
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Help with SAAJ and SOAP 1.2