users@jax-rpc.java.net

Re: Upgrade to Java 1.6 killed my app!

From: V B Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
Date: Thu, 22 Mar 2007 11:44:00 +0530

Hi,

    JDK6 has SAAJ integrated into the platform. SAAJ 1.2 never had
support SOAP 1.2 documents so i am a little suprised when you say it
used to work earlier. SAAJ 1.3 is what is integrated into JDK6 as well
as available standalone from saaj.dev.java.net. The internal
implementation package names are different inside JDK and when used
standalone.

   Here is what you need to do if you want to load a SOAP 1.2 document.

import javax.xml.soap.SOAPConstants;

MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);

Note that the API MessageFactory.newInstance() was defined in earlier versions of SAAJ API and meant SOAP 1.1.

If you need a message Factory that should work for both SOAP 1.1 and 1.2 envelopes then you need to do the following :

MessageFactory factory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL);

But NOTE that factory.createMessage() would then throw UnsupporteOperationException.



Let me know if this helped...

regards,
kumar

syg6 wrote:

>Hello all,
>
>I recently upgraded to Java 1.6 and now when I try to upload and parse a
>SOAP 1.2 document it poops the bed.
>
>This is my code:
>
>StringReader sr = new StringReader(pXml);
>StreamSource ss = new StreamSource(sr);
>MessageFactory mf = MessageFactory.newInstance();
>SOAPMessage soapMessage = mf.createMessage();
>SOAPPart soapPart = soapMessage.getSOAPPart();
>soapPart.setContent(ss);
>SOAPEnvelope env = soapPart.getEnvelope();
>
>pXml is a String containing the uploaded SOAP document, whose Envelope
>section has the SOAP 1.2 uri (http://www.w3.org/2003/05/soap-envelope/).
>When I use the SOAP 1.1 uri (http://schemas.xmlsoap.org/soap/envelope/) it
>works fine. It also used to work fine on Java 1.5.
>
>The error is:
>
>
>
>>21-mar-2007 17:19:30 com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl
>>
>>
>lookForEnvelope
>
>
>>GRAVE: SAAJ0513: Unable to create envelope from given source because the
>>
>>
>namespace was not recognized
>
>I went and downloaded the latest saaj jar but that didn't help. What I found
>interesting was that my old saaj (1.2) was just one jar -- saaj.jar, which
>contained javax.xml.soap.*.
>
>The new saaj (1.3) is comprised of 2 jars -- saaj-api.jar which seems to
>contain the same classes as saaj 1.2, and saaj-impl.jar, which seems to
>contain classes with the same names as those found in Java 1.6's rt.jar. The
>difference is the path to those classes:
>
>Java 1.6 rt.jar
>com\sun\xml\internal\messaging\saaj.*
>
>saaj-impl.jar
>com.sun.xml.messaging.saaj.*
>
>Anyway, I tried copying the two saaj jars into my project but no-go, same
>error. Can anyone tell me how to get Java 1.6 to work with SOAP 1.2
>documents?
>
>Many thanks!
>
>Bob
>
>