Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tomas-Kraus opened this issue Jul 28, 2015 · 4 comments
Open

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

Tomas-Kraus opened this issue Jul 28, 2015 · 4 comments

Comments

@Tomas-Kraus
Copy link
Member

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]

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Reported by ParanoidUser

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Was assigned to gagordon

@Tomas-Kraus
Copy link
Member Author

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

@Tomas-Kraus
Copy link
Member Author

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

No branches or pull requests

2 participants