• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Help with SAAJ and SOAP 1.2

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
     
    Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic