axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Edwardson" <bun...@tpg.com.au>
Subject Re: Soap Header headaches
Date Tue, 29 Apr 2003 21:52:23 GMT
Thanks Phil, when I get my custom Handler to actually get invoked, this code will be most usefull.
  ----- Original Message ----- 
  From: Phil Bohnenkamp 
  To: 'axis-user@ws.apache.org' 
  Sent: Tuesday, April 29, 2003 11:55 PM
  Subject: RE: Soap Header headaches


  Larry,

  Here is a little code that I know works for me, maybe it will help get you started...

      // The add header method needs a DOM Element so make
      // the contents of the cp_soap_header element as a string
      // and make it into an element
      DocumentBuilderFactory factory = 
        DocumentBuilderFactory.newInstance();
              factory.setNamespaceAware(true);
      DocumentBuilder builder = factory.newDocumentBuilder();
   
      Document doc = builder.parse(new InputSource(new StringReader(
        _soapCallXml.getCpSoapHeaderAsString())));
      
      SOAPHeaderElement hElement = new SOAPHeaderElement(
        doc.getDocumentElement());

      call.addHeader(hElement);

  To get the header (this is in a custom handler ...)

      // This is the request so grab the objecy from the header
      Iterator it = msgContext.getMessage().getSOAPPart().
        getEnvelope().getHeader().getChildElements();

      while(it.hasNext())
      {
       idHeader = (SOAPHeaderElement) it.next();
       try {
        if(idHeader.getRealElement().getAsDocument().getFirstChild().getNodeName().equals(
          "String"))
        {
         break;
        }
       } catch (Exception e) {
              // do something with the exception
       }
      }

  Hope this helps,

  Phil.

  Phillip Bohnenkamp
  Engagement Engineer
  Centerpost
  200 W. Monroe St.
  Suite 1400
  Chicago, IL 60606
  312.224.9508 


    -----Original Message-----
    From: Larry Edwardson [mailto:bunnys@tpg.com.au]
    Sent: Monday, April 28, 2003 5:45 PM
    To: Axis-user
    Subject: Soap Header headaches


    Does anyone have an example of using soap headers, I have been trying for a few days now
to access the headers on the service side with no luck, firstly I tried to gain access to
the MessageContext which comes back as null ? I have also tried writing my own handler but
with no success, I am just about to scream, surely it cant be that hard, all I need to do
is send a username and password and authorise the user.

    Any response will be gladely appreciated.

    Cheers Larry
Mime
View raw message