axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Upul Godage" <upulg....@gmail.com>
Subject Re: using custom handler to access soap header
Date Fri, 09 May 2008 19:42:43 GMT
SOAPHeader header = env.getHeader(); gives you the <soap:Header>
To access the header elements inside it you can use methods like,
java.util.Iterator iterHeaderElements = header.examineAllHeaderElements()
which will return SOAPHeaderElements

Upul

On Sat, May 10, 2008 at 12:20 AM, nipa dadbhawala <nipadadbhawala@gmail.com>
wrote:

> Hi,
>
> I have a web service and a test client. I have written a custom handler to
> access custom soap header sent by the client. Following is the code snippet
> in invoke method
>
> public InvocationResponse invoke(MessageContext messageContext) throws
> AxisFault
>  {
>      SOAPEnvelope env = messageContext.getEnvelope();
>      SOAPHeader header = env.getHeader();
>
>      System.out.println("Local name = " + header.getLocalName());
>      System.out.println("Namespace = " + header.getNamespace());
>      System.out.println("QName = " + header.getQName());
>       System.out.println("Text = " + header.getText());
>
> On the client side I have the code as follows to add the custom SOAP
> header.
>
> SericeClient sc = myStub.getServiceClient();
> sc.addStringHeader(new QName("http://www.CustomHeaders.com",
> "CustomHeader", "CusotmNS"), "Some Information");
>
> The values I am getting on the server side is as follows.
>
> Local name = Header
> Namespace = org.apache.axiom.om.impl.OMNamespaceImpl@212ecf42
> QName = {http://schemas.xmlsoap.org/soap/envelope/}Header<http://schemas.xmlsoap.org/soap/envelope/%7DHeader>
> Text =
>
> On the server size I also tries this code and I am getting the size as
> zero.
>
> ArrayList listHeaders = msgContext.getAxisMessage().getSoapHeaders();
>             System.out.println("listHeaders size = " + listHeaders.size());
>             for(int i =0; i< listHeaders.size(); i++)
>             {
>                 SOAPHeaderMessage soapHeaderMsg =
> (SOAPHeaderMessage)listHeaders.get(i);
>                 System.out.println("element = "
> +soapHeaderMsg.getElement().toString());
>                 System.out.println("message = "
> +soapHeaderMsg.getMessage().toString());
>                 System.out.println("Namespace URI = " +
> soapHeaderMsg.getNamespaceURI());
>             }
>
> I do not see the header I am sending through my client. Can pl. someone
> help me with this problem?
>
> Thanks,
> Nipa
>
>

Mime
View raw message