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

Parsing SOAP request encoded to UTF-8 with BOM #79

Open
glassfishrobot opened this issue Jul 28, 2015 · 3 comments
Open

Parsing SOAP request encoded to UTF-8 with BOM #79

glassfishrobot opened this issue Jul 28, 2015 · 3 comments

Comments

@glassfishrobot
Copy link
Contributor

I have SOAP Client based on HttpClient and SAAJ (provided by JDK 1.7.0_65 or used from maven dependencies - "com.sun.xml.messaging.saaj.saaj-impl.1.3.25").

When I receive the SOAP response that has UTF-8 charset with BOM, I observe the following exception:
Caused by: java.io.IOException: Unexpected characters before XML declaration
at com.sun.xml.internal.messaging.saaj.util.XMLDeclarationParser.parse(XMLDeclarationParser.java:120)[:1.7.0_65]
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.lookForXmlDecl(SOAPPartImpl.java:645)[:1.7.0_65]
...

Retrived SOAP response:
[0xef][0xbb][0xbf]
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header />
env:Body
Hello, SOAP!
</env:Body>
</env:Envelope>

Sample code to reproduce a problem:
@test
public void testCreateSoapResponseWithUTF8AndBOM() throws Exception
{
try (InputStream responseContent = Resources.getTemplate("soap-request-utf8.xml-with-bom.xml"))

{ MimeHeaders mimeHeaders = new MimeHeaders(); mimeHeaders.addHeader(HttpHeaders.CONTENT_TYPE, "application/soap+xml; charset="utf-8""); MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL); SOAPMessage message = messageFactory.createMessage(mimeHeaders, responseContent); message.saveChanges(); message.getSOAPHeader(); }

}

I found a topic with the similar problem at SAAJ (dated 2008), but it doesn't describe a solution.
https://java.net/projects/saaj/lists/users/archive/2008-07/message/6

I hope for your help.

Affected Versions

[1.3.16]

@glassfishrobot
Copy link
Contributor Author

Reported by ParanoidUser

@glassfishrobot
Copy link
Contributor Author

Was assigned to gagordon

@glassfishrobot
Copy link
Contributor Author

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

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