javaweb-servicessaaj

SOAPAction not setting properly - Java


I am trying to add SOAPAction to my SOAP web request.

Following is my code:

    return (TPResponse) getWebServiceTemplate().marshalSendAndReceive(genTP, message -> {
        ((SaajSoapMessage)message).setSoapAction("http://tempuri.org/GenerateParam");
    });

Expectations are that this code should add a separate header field in my HTTP request as SOAPAction: "http://tempuri.org/GenerateParam". But following is what final packet is formed:

POST /myscripts/script.php?somedetails HTTP/1.1
Accept-Encoding: gzip
Accept: application/soap+xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type: application/soap+xml; charset=utf-8; 
    action="http://tempuri.org/GenerateParam"
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.8.0_73
Host: 127.0.0.1
Connection: keep-alive
Content-Length: 578

Please note that rather than adding separate HTTP Header it has modified Content-Type and added action with value in it. What could be wrong?


Solution

  • Found the issue. I just changed the Soap Protocol of my SaajSoapMessageFactory from SOAP_1_2_PROTOCOL to SOAP_1_1_PROTOCOL and it started working properly.