You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Anuj Agrawal <ag...@lucent.com> on 2001/06/20 20:56:57 UTC

adding headers to a SOAP packet programmatically

I've read thru' the few postings regarding headers in SOAP, but don't seem to
have an answer.

I have a Java SOAP client that programmatically creates a SOAP packet.  Since
i'm accessing the SOAP server using the rpcrouter (via a web server of course),
i would like to be able to add header info to the packet so that the web server
logs reflect that info.

Specifically i would like to add the user-agent header.

So, based on a suggestion by Collin Goredema, i tried the following but to no
avail.

	Vector vr = new Vector();
        Header hr = new Header();
        Element theElem = null;
        try
        {
            Document doc = (Document)
Class.forName("org.apache.xerces.dom.DocumentImpl").newInstance();
            theElem = doc.createElement("user-agent");
            theElem.appendChild(doc.createTextNode( "my personalized user agent
name"));
        }
        catch (Exception e)
        {
        }
        vr.addElement(theElem);
        hr.setHeaderEntries(vr);
        Call call = new Call();
        call.setHeader(hr);

Any other suggestions?
Thanks.
Anuj.