axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "nipa dadbhawala" <nipadadbhaw...@gmail.com>
Subject Re: using custom handler to access soap header
Date Wed, 14 May 2008 15:59:35 GMT
Hi Upul,

Thanks. This solution has worked. Earlier I tried using
extractAllHeaderBlocks and it gave me UnsupportedOperation exception. I
never tried examineAllHeaderBlocks before your email. Now I can see the
custom header sent by the client.

Thanks a lot for your help.

Nipa

On Tue, May 13, 2008 at 7:17 AM, Upul Godage <upulg.dev@gmail.com> wrote:

> I think msgContext.getEnvelope().getHeader().examineAllHeaderBlocks();
> should return an iterator of header blocks.  Check whether any headers exist
> in the SOAP message by using a tool like TCPMon or printing or debugging the
> SOAP envelope.
>
> Upul
>
>
>
> On Tue, May 13, 2008 at 2:32 AM, nipa dadbhawala <nipadadbhawala@gmail.com>
> wrote:
>
>> Hi Upul,,
>> I also tried the following code and it is giving me ClassCastEception on
>> the highlighted line. ANy help would be appreciated.
>>
>>
>> SOAPEnvelope env = msgContext.getEnvelope();
>>
>>
>>         if(env != null)
>>         {
>>
>>             SOAPHeader header = env.getHeader();
>>
>>             SOAPHeaderImpl impl = new SOAPHeaderImpl(header);
>>
>>            System.out.println("SOAPHeadewrImpl got created");
>>             Iterator it = impl.examineAllHeaderElements();
>>             if(it != null)
>>             {
>>                 while(it.hasNext())
>>                 {
>>
>>                     SOAPHeaderElement element
>> =(SOAPHeaderElement)it.next();
>>                     Name name = element.getElementName();
>>                     System.out.println("SOAPHeaderElement element name = "
>> + name.toString());
>>                     System.out.println("SOAPHeaderElement node name/value
>> = " + element.getNodeName()  + " " + element.getNodeValue());
>>                     System.out.println("SOAPHeaderElement element prefix =
>> " + element.getPrefix());
>>
>>
>>
>>                 }
>>             }
>>
>> Thanks,
>> Nipa
>>
>>
>> On Fri, May 9, 2008 at 4:56 PM, nipa dadbhawala <nipadadbhawala@gmail.com>
>> wrote:
>>
>>> Hi Upul,
>>>
>>> Thanks for your email. From messageContext I get the SOAPEnvelope of type
>>> org.apache.axiom.soap and the same with SOAPHeader which I get from
>>> SOAPEnvelope. Now on org.apache.axiom.soap.SOAPHeader there is no method
>>> examineAllHeaderElements() defined. Instead I tried using
>>> extractAllHeaderBlocks and that did not help. The method
>>> extractAllHeaderBlocks is defined on javax.xml.soap.SOAPHeader.
>>> Any further help is appreciated.
>>>
>>> Thanks,
>>> Nipa
>>>
>>>
>>>
>>>
>>> On Fri, May 9, 2008 at 12:42 PM, Upul Godage <upulg.dev@gmail.com>
>>> wrote:
>>>
>>>> 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