Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Provide ability to parse SOAP1.1 or SOAP 1.2 messages #21

Open
glassfishrobot opened this issue Mar 22, 2007 · 4 comments
Open

Provide ability to parse SOAP1.1 or SOAP 1.2 messages #21

glassfishrobot opened this issue Mar 22, 2007 · 4 comments

Comments

@glassfishrobot
Copy link
Contributor

Email discussion of the issue :

I would like to be able to parse both SOAP 1.1 and 1.2. So if I use
DYNAMIC_SOAP_PROTOCOL I must use createMessage(MIMEHeaders, InputStream).
But I don't have MIMEHeaders or an InputStream, I only have the string,
pXml.

So is the only way to do this to get the uri of the namespace associated
with the Envelope and put an 'if'? IOW:

if (uri.equals('http://www.w3.org/2003/05/soap-envelope/')
factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
else factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);

This seems kind of kludgy. What happens when SOAP 1.3 comes out? I would
think that the existence of a DYNAMIC_SOAP_PROTOCOL constant would indicate
that it recognizes the document ... you know, dynamically?

Anything other than this kludgy 'if' that I can do?

Thanks,
Bob

V B Kumar Jayanti wrote:

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.

User Code :

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.

Environment

Operating System: Windows XP
Platform: All

Affected Versions

[current]

@glassfishrobot
Copy link
Contributor Author

Reported by @vbkumarjayanti

@glassfishrobot
Copy link
Contributor Author

Was assigned to saaj-issues

@glassfishrobot
Copy link
Contributor Author

@vbkumarjayanti said:
MessageFactory factory =
MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL);

followed by

factory.createMessage(null, InputStream) could be handled in such a way that the
content-type is detected from the inputstream. It may require InputStream to
support mark and reset (not sure about this at the moment, need to investigate
more into the RI).

@glassfishrobot
Copy link
Contributor Author

This issue was imported from java.net JIRA SAAJ-21

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant