How to modify headers in the SOAP response. Below snippet will do the trick. In a nutshell, you need to: Add @SoapHeader annotation in the service method. Use Unmarshaller to map header xml elements to java object. Make necessary changes to this java object. Finally, use Marshaller to map java object back to xml, and set in response. // Service class code private static final String NAMESPACE_URI = "http://domain.com/context/../DummyRequest.xsd"; @PayloadRoot(namespace = NAMESPACE_URI, localPart = "RequestPartInXml") @ResponsePayload public JAXBElement<ResponsePOJO> returnApiResponse( @RequestPayload JAXBElement<RequestPojo> request, @SoapHeader(value = "{http://domain.com/context/../DummyRequest.xsd}MessageHeader") SoapHeaderElement soapHeaders, MessageContext messageContext) { // handleSoap Headers handleSoapHeaders(messageContext, soapHeaders); ... ... } // handling of headers pub
A technical blog meant for IT professionals..