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 "Yu, Joel, Contractor" <Jo...@asamra.hoffman.army.mil> on 2004/06/22 20:35:24 UTC

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();
    }

  }
}