Announcement Announcement Module
Collapse
No announcement yet.
How to get SOAP Header of response using WebServiceTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get SOAP Header of response using WebServiceTemplate

    Hello,

    I am beginner in Spring-WS. I am using WebServiceTemplate to call SOAP web service.
    Login service require authentication details in SOAP header. I have done that using WebServiceMessageCallback.

    when i call login method, it returns session token in SOAP header :

    Code:
    StreamResult result = new StreamResult(new StringWriter());
    webServiceTemplate.sendSourceAndReceive(source, webserviceMessageCallBack, result);
    return result;
    Actual output/response of above request is as below:

    Code:
    <SOAP:Envelope>
        <SOAP:Header>
            <Security>
                <Token>asdlkf8489lsldkFGIO9349dk</Token>
            </Security>
        </SOAP:Header>
        <SOAP:Body>
            <LogonResponse>OK</LogonResponse>
        <SOAP:Body>
    </SOAP:Envelope>
    When i print result, It prints only body part of response.
    Code:
            <LogonResponse>OK</LogonResponse>
    How can i get header part of response to get value of token?

    Please help. Thanks

  • #2
    You could try implementing a ClientInterceptor and adding it to the WebServiceTemplate interceptors property.
    The interceptor returns a MessageContext the getRequest() and getResponse() methods can get you the WebServiceMessage.
    You could down cast the to a WebServiceMessage to SoapMessage which has getSoapHeader().

    Comment

    Working...
    X