axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricky Ho <r...@cisco.com>
Subject RE: Handlers and SOAP message re-writing
Date Fri, 06 Sep 2002 15:53:30 GMT
Following is my exact code based on AXIS beta 2

import org.apache.axis.*;
import org.apache.axis.handlers.*;
import org.apache.axis.message.*;

public class PutHeaderHandler extends BasicHandler {
     public void invoke(MessageContext msgContext) throws AxisFault
     {
         try {
                 System.out.println(" -- PutHeaderHandler starts --");
                 System.out.println("Options are :  " + getOptions());

                 SOAPEnvelope envelope = 
msgContext.getRequestMessage().getSOAPEnvelope();
                 System.out.println("Request message is : " + envelope);
                 envelope.addHeader(new SOAPHeaderElement("TestNameSpace", 
"isAuthenticated", new Boolean(true)));

                 System.out.println("Add header");
        } catch (Exception e) {
             throw AxisFault.makeFault(e);
         }
     }
}

Rgds, Ricky

At 10:29 AM 9/6/2002 -0500, you wrote:
>Indeed I have tried just printing out the envelope before the invoke()
>method exits. It's the same message I got before I changed it -- it was not
>modified at all.
>
>Something's amiss here. Would you mind posting (a cleansed version of) your
>code? I'd be curious to see the exact method calls you're using.
>
>Rob
>
>-----Original Message-----
>From: Ricky Ho [mailto:riho@cisco.com]
>Sent: Thursday, September 05, 2002 6:05 PM
>To: axis-user@xml.apache.org; axis-user@xml.apache.org
>Subject: RE: Handlers and SOAP message re-writing
>
>
>I'm using the Beta 2 version, and it works fine.
>
>Have you print out the request message right before your handler returns
>and see if it has been modified ?
>
>Best regards,
>Ricky
>
>At 06:40 PM 9/5/2002 -0500, Allegar Robert wrote:
> >Ricky,
> >         I'd be curious to see what version you're running, then. I
> > modified your
> >code so it would compile and tried it in my handler. I think the call you
> >wanted was envelope.addChildElement(). There is no envelope.addHeader()
> >method which takes a SOAPHeaderElement. Your modified code looks like this
>:
> >
> >                 SOAPEnvelope envelope =
> > context.getRequestMessage().getSOAPEnvelope();
> >                 SOAPHeader header = envelope.getHeader();
> >                 header.addHeaderElement(envelope.createName("localName",
> > "prefix",
> >"URI"));
> >
> >
> >When I tested it the request that came into my handler is the same request
> >that leaves it. Nothing is changed. I have two handlers in my architecture
> >before the webservice is called. One contains the code you gave me, and
> >another one deployed second in the chain merely logs the soap request to
> >System.out:
> >                         SOAPMessage message = context.getMessage();
> >                         message.writeTo(System.out);
> >
> >         I am 100% sure that the first handler containing your code is
> > deployed and
> >is being called because there are debugging steps throughout my invoke()
> >method.
> >
> >         I've been trying various permutations of this same code for the
> > past few
> >days now. It just doesn't seem possible to be able to change request
>(either
> >header or body) in one handler and then have the change reflected either in
> >the rest of the handler chain or in the called web service.
> >
> >Regards,
> >         Rob
> >
> >
> >-----Original Message-----
> >From: Ricky Ho [mailto:riho@cisco.com]
> >Sent: Thursday, September 05, 2002 5:01 PM
> >To: axis-user@xml.apache.org
> >Subject: RE: Handlers and SOAP message re-writing
> >
> >
> >Albert,
> >
> >Just curious why you add a child element under the SOAP envelope, because
>it
> >should only have "header" and "body".
> >Below is some of my code to add some header information to the request
> >message.  And it works fine.
> >
> >                 SOAPEnvelope envelope =
> >msgContext.getRequestMessage().getSOAPEnvelope();
> >                 System.out.println("Request message is : " + envelope);
> >                 envelope.addHeader(new SOAPHeaderElement("MyNameSpace",
> >"headerXYZ", "Value of HeaderXYZ"));
> >
> >Also check your handler is properly installed and has been executed.
> >
> >Best regards,
> >Ricky
> >
> >
> >-----Original Message-----
> >From: Allegar Robert [mailto:allegar_robert@bah.com]
> >Sent: Thursday, September 05, 2002 1:14 PM
> >To: axis-user@xml.apache.org
> >Subject: Handlers and SOAP message re-writing
> >
> >
> >Is the SOAP message considered read-only when it's being handled by the
> >handlers? I'm trying to use a value in the header I receive to look up a
> >value to place in the body. I've extracted out the essence of this in the
> >following lines of code:
> >
> >         Message requestMessage = context.getRequestMessage();
> >         SOAPEnvelope envelope = requestMessage.getSOAPEnvelope();
> >         SOAPElement element = envelope.addChildElement("testElement");
> >         element.addTextNode("testElementNode");
> >
> >This code exists in a handler. Unfortunately, the SOAP message that's
> >leaving the handler does not contain the new element I've just added -- it
> >almost appears the message is read-only, though no faults or exceptions are
> >thrown.
> >
> >The thing that troubles me is that this code works as it should under
> >Weblogic 7.0's webservice impl. Am I doing something wrong, calling the
> >wrong APIs or is this a bug?
> >
> >Regards,
> >         Rob

Mime
View raw message