0

I created

public class ExceptionHandler implements SOAPHandler<SOAPMessageContext>

I want to create soap header with non-ascii characters.

MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapMsg = factory.createMessage();
//soapMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "utf-8");
SOAPHeaderElement aaa = soapMsg.getSOAPHeader().addHeaderElement(new QName("test", "aaa"));
aaa.addTextNode("ść");
context.setMessage(soapMsg);

What i get in response is:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header>
       <aaa xmlns="test">ść</aaa>
   </env:Header>
   <env:Body/>
</env:Envelope>

Does this api do not support nonascii characters or is it a bug?

zerocool
  • 103
  • 1
  • 7
  • 1
    It’s not a bug. Either you are viewing the XML in an editor that thinks the XML is in a one-byte encoding (like windows-125x) instead of UTF-8, or the Java compiler assumed your source file was using a one-byte encoding when in fact it was using UTF-8. – VGR Oct 21 '19 at 16:47
  • yes it was a matter of project.build.sourceEncoding in maven project (default encoding of maven-compiler-plugin) – zerocool Oct 22 '19 at 07:36

0 Answers0