Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SPRING WS misses "<?xml version="1.0" encoding="UTF-8"?>"

I use spring ws.

How could I add this <?xml version="1.0" encoding="UTF-8"?> to my first line in the response?

I tried this block of code but It doesn't work. Could anybody help me?

@Bean (name = "messageFactory")
public SaajSoapMessageFactory messageFactory () {
    Map<String, Object> props = new HashMap<>();
    props.put(SOAPMessage.WRITE_XML_DECLARATION, Boolean.TRUE);

    SaajSoapMessageFactory msgFactory = new SaajSoapMessageFactory();
    msgFactory.setMessageProperties(props);
    msgFactory.setSoapVersion(org.springframework.ws.soap.SoapVersion.SOAP_11);

    return msgFactory;
}
like image 929
Matus Avatar asked Mar 05 '26 20:03

Matus


1 Answers

Well at least it worked for me, thanks a lot !

I just changed the value from Boolean.TRUE to "true":

@Bean (name = "messageFactory")
    public SaajSoapMessageFactory messageFactory () {
        Map<String, Object> props = new HashMap<>();
        props.put(SOAPMessage.WRITE_XML_DECLARATION, "true");

        SaajSoapMessageFactory msgFactory = new SaajSoapMessageFactory();
        msgFactory.setMessageProperties(props);
        msgFactory.setSoapVersion(org.springframework.ws.soap.SoapVersion.SOAP_11);

        return msgFactory;
    }
like image 188
PleaseDoMyHomework Avatar answered Mar 08 '26 09:03

PleaseDoMyHomework



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!