axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sanjiva Weerawarana" <sanj...@opensource.lk>
Subject Re: what's wrong with this code
Date Wed, 23 Jun 2004 03:21:30 GMT
Actually you can add children .. I did the following yesterday to generate
some WS-Addressing headers and it worked fine:

    SOAPHeaderElement replyToHeader =
      new
SOAPHeaderElement("http://schemas.xmlsoap.org/ws/2003/03/addressing",
                            "ReplyTo");
    replyToHeader.addChild
      (new MessageElement
("http://schemas.xmlsoap.org/ws/2003/03/addressing",
                           "Address",

(Object)"http://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous"));

Sanjiva.

----- Original Message ----- 
From: "Jarek Gawor" <gawor@mcs.anl.gov>
To: <axis-dev@ws.apache.org>
Sent: Wednesday, June 23, 2004 3:08 AM
Subject: RE: what's wrong with this code


Once you create some subclass of MessageElement (e.g. SOAPHeaderElement)
with a DOM Element, or a some value you cannot add children to it. Well, you
can but they won't be serialized properly as your test program shows. In
this case, just use a different constructor - for example:

    SOAPHeaderElement soapHeader =
          new SOAPHeaderElement("http://localhost/", "header");

This hopefully be improved one way.

Jarek

> -----Original Message-----
> From: Yu, Joel, Contractor
> [mailto:Joel.Yu.Ctr@asamra.hoffman.army.mil]
> Sent: Tuesday, June 22, 2004 2:28 PM
> To: 'axis-dev@ws.apache.org'
> Subject: what's wrong with this code
>
>
> when i run the following code, i get:
> soapelement is:<headerChild xmlns="">test</headerChild>
> header is:<ns1:header xmlns:ns1="http://localhost/"></ns1:header>
>
> why doesn't the header include soapelement?
>
>
> import org.apache.axis.message.SOAPHeaderElement;
> import org.apache.axis.message.SOAPEnvelope;
> import javax.xml.soap.SOAPElement;
> import org.apache.axis.utils.XMLUtils;
>
> public class Test {
>   public Test() {
>   }
>
>
>   public static void main(String[] args) {
>     try {
>       SOAPEnvelope soapEnvelope = new SOAPEnvelope();
>       SOAPHeaderElement soapHeader =
>           new SOAPHeaderElement(
>           XMLUtils.StringToElement(
>           "http://localhost/", "header",
>           ""));
>       SOAPElement se =
> soapHeader.addChildElement("headerChild", "", "");
>       se.addTextNode("test");
>       soapEnvelope.addHeader(soapHeader);
> System.out.println("soapelement is:"+se);
> System.out.println("header is:"+soapHeader);
>     }
>     catch(Exception e) {
>       e.printStackTrace();
>     }
>
>   }
> }
>
>



Mime
View raw message