1

When I add soap headers from handler.handlResponse(), I can see the headers added in the handler but these headers do not make it to the client.

Here is my handleResponse() method.

    public static final String WEB_SERVICE_NAMESPACE_PREIFX = "dm";
    public static final String WEB_SERVICE_NAMESPACE_URI    = "urn:com.qwest.dms.dto";
    public boolean handleResponse(MessageContext context)
    {
        logger.debug("TransactionLoggerHandler.handleResponse invoked");
        try
        {
            SOAPMessageContext soapContext;
            soapContext = (SOAPMessageContext)context;
            SOAPMessage message = soapContext.getMessage();
            SOAPHeader soapHeader = message.getSOAPHeader();
            String version = "version";
            SOAPHeaderElement header;
            SOAPFactory soapFactory;

            Name name;

            logger.debug("Adding soap header ["+version+"] with value [2.0].");

            soapHeader.addNamespaceDeclaration(Constants.WEB_SERVICE_NAMESPACE_PREIFX, Constants.WEB_SERVICE_NAMESPACE_URI)
            SOAPHeaderElement headerElement
                = (SOAPHeaderElement)message.getSOAPPart().getEnvelope().getHeader().addChildElement(
                    "version",
                    Constants.WEB_SERVICE_NAMESPACE_PREIFX,
                    Constants.WEB_SERVICE_NAMESPACE_URI );
            headerElement.addTextNode("2.0");

            String headerName="protocol";
            String headerValue="2.0.0";
            logger.debug("Adding soap header ["+headerName+"] with value ["+headerValue+"].");
            soapFactory = SOAPFactory.newInstance();
            name = soapFactory.createName(headerName, 
                                        Constants.WEB_SERVICE_NAMESPACE_PREIFX,    
                                        Constants.WEB_SERVICE_NAMESPACE_URI );    
            header = soapHeader.addHeaderElement( name ); 
            header.addTextNode(headerValue);
            message.saveChanges();

            DmsUtil.printSOAPMessage(message);
            logger.debug("Soap header ["+version+"] with value [2.0] added.");                  
        }
        catch (Exception e)
        {
            logger.error(e);
        }

        return true;
    }




I see the output from this method as the following:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header xmlns:dm="urn:com.qwest.dms.dto">
   <dm:version>2.0</dm:version>
   <dm:protocol>2.0.0</dm:protocol>
</env:Header>
<env:Body>

From the Client i get the following:

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

I am not sure why these headers not sent over the wire. Any help is appreciated. BTW, I am using jax rpc webservices under jboss4 (I know, i have to upgrade this but can not due to some constraints :( ).

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Sannu
  • 1,202
  • 4
  • 21
  • 32

0 Answers0