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 Plorks mail <pl...@hotmail.com> on 2005/04/26 17:09:51 UTC

custom header elements SOAP messages


Hello

Please can someone help me

I've partly created a handler, code below

I want to simply test this with a client that can add a soap header, can 
someone show me how to do this?

I'm not sure how to create a client

I then need to be able to pass vlaues back to the server-side from the 
client-side =- how can i do this?

Any help reatly appreciated




public void invoke(MessageContext msgContext) throws AxisFault
    {
        handleRequest(msgContext);
        super.invoke(msgContext);
    }


    public boolean handleResponse(MessageContext msgContext)
    {
        try
        {
            Message message = msgContext.getRequestMessage();
            SOAPEnvelope requestEnvelope = message.getSOAPEnvelope();
            SOAPHeaderElement headerElement = 
requestEnvelope.getHeaderByName("http://domain","TokenHeader");

            if (headerElement != null)
            {
                String headerElementValue = 
(String)headerElement.getValue();

                // make sure the headerElementValue is valid
                validateTokenValue(headerElementValue);
            }
            else
            {
                // something's gone wrong

                // no header TokenHeader found, therefore we need to create 
a header element and return to client

                // get userName and password
                // pass to db to validate

                //SOAPHeaderElement responseHeaderElement = new 
SOAPHeaderElement("http://domain","TokenHeader");
                //responseHeaderElement.setObjectValue(sTokenValue);
            }
        }
        catch(Exception e)
        {
            System.out.println(e);
        }

        return true;
    }


    public boolean handleRequest(MessageContext msgContext)
    {
        try
        {
            //SOAPEnvelope responseEnvelope = 
msgContext.getResponseMessage().getSOAPEnvelope();
            Message message = msgContext.getResponseMessage();
            SOAPEnvelope responseEnvelope = message.getSOAPEnvelope();

        }
        catch(Exception e)
        {
            System.out.println(e);
        }

        return true;
    }

_________________________________________________________________
Winks & nudges are here - download MSN Messenger 7.0 today! 
http://messenger.msn.co.uk