axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jarek Gawor" <ga...@mcs.anl.gov>
Subject RE: what's wrong with this code
Date Tue, 22 Jun 2004 21:08:44 GMT
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