You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ao...@meridianp2p.com on 2004/07/22 11:11:21 UTC

Adding element to Soap header in client handler

Hi,

I need to add an element to my SOAP header in a client side handler.  In 
the invoke() method of my handler i can extract the SOAPEnvelope and 
SOAPHeader.  I can create a new SOAPHeaderElement and add that to the soap 
header.  However, I do not want the element to have the mustUnderstand or 
actor attributes associated with it.  Setting the actor to the empty 
string removes the latter for me, but I can't get rid of the first. 
I tried creating a MessageElement object instead of a SOAPHeaderElement 
but whenever I attempt to add it to my header at runtime I get the message
        a SOAPHeader may only have SOAPHeaderElement as its immediate children

Can somebody please help me out with this please?  The code (using the 
MessageElement) is as follows:
        MessageElement she = new MessageElement(
                new QName("http://some.service.url/schemas/service/", "Operation"), "Form11/File");
 
        Message message = messageContext.getRequestMessage();

        SOAPEnvelope envelope = message.getSOAPEnvelope();
        MessageElement headerElement = 
(MessageElement)envelope.getHeader();
        headerElement.addChild(she);

It appears the headerElement.addChild invocation is what is causing my 
error message above.  The reason I am casting and using MessageElement is 
to try and avoid the placing of the mustUnderstand and actor attributes in 
my generated element.

Any help much appreciated.
Thanks,
Aoife