axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/message SOAPHeader.java
Date Thu, 20 Mar 2003 13:30:45 GMT
dims        2003/03/20 05:30:45

  Modified:    java/test/saaj PackageTests.java
               java/src/org/apache/axis/message SOAPHeader.java
  Added:       java/test/saaj TestHeaders.java
  Log:
  Fix for Bug 18183 - ClassCastException after header.addChildElement
  
  Revision  Changes    Path
  1.6       +1 -0      xml-axis/java/test/saaj/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/saaj/PackageTests.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PackageTests.java	17 Dec 2002 20:10:54 -0000	1.5
  +++ PackageTests.java	20 Mar 2003 13:30:45 -0000	1.6
  @@ -20,6 +20,7 @@
           }catch( Throwable t){;}
           suite.addTestSuite(test.saaj.TestEnvelope.class);
           suite.addTestSuite(test.saaj.TestSOAPFaultDetail.class);
  +        suite.addTestSuite(test.saaj.TestHeaders.class);
           return suite;
       }
   }
  
  
  
  1.1                  xml-axis/java/test/saaj/TestHeaders.java
  
  Index: TestHeaders.java
  ===================================================================
  package test.saaj;
  
  import javax.xml.soap.MessageFactory;
  import javax.xml.soap.SOAPEnvelope;
  import javax.xml.soap.SOAPHeader;
  import javax.xml.soap.SOAPMessage;
  import java.io.ByteArrayOutputStream;
  
  public class TestHeaders extends junit.framework.TestCase {
  
      public TestHeaders(String name) {
          super(name);
      }
  
      public void testAddingHeaderElements() throws Exception {
          SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
          SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
          SOAPHeader header = soapEnv.getHeader();
          header.addChildElement("ebxmlms");
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          soapMessage.writeTo(baos);
          String xml = new String(baos.toByteArray());
          assertTrue(xml.indexOf("ebxmlms") != -1);
      }
  }
  
  
  
  1.71      +38 -0     xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
  
  Index: SOAPHeader.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- SOAPHeader.java	18 Mar 2003 18:36:02 -0000	1.70
  +++ SOAPHeader.java	20 Mar 2003 13:30:45 -0000	1.71
  @@ -393,4 +393,42 @@
         } 
         return super.addChildElement(element);
       }
  +
  +    public SOAPElement addChildElement(Name name) throws SOAPException {
  +        SOAPHeaderElement child = new SOAPHeaderElement(name.getURI(),
  +                                                  name.getLocalName());
  +        addChild(child);
  +        child.setEnvelope(getEnvelope());
  +        return child;
  +    }
  +
  +    public SOAPElement addChildElement(String localName) throws SOAPException {
  +        // Inherit parent's namespace
  +        SOAPHeaderElement child = new SOAPHeaderElement(getNamespaceURI(),
  +                                                  localName);
  +        addChild(child);
  +        child.setEnvelope(getEnvelope());
  +        return child;
  +    }
  +
  +    public SOAPElement addChildElement(String localName,
  +                                       String prefix) throws SOAPException {
  +        SOAPHeaderElement child = new SOAPHeaderElement(getNamespaceURI(prefix),
  +                                                  localName);
  +        addChild(child);
  +        child.setEnvelope(getEnvelope());
  +        return child;
  +    }
  +
  +    public SOAPElement addChildElement(String localName,
  +                                       String prefix,
  +                                       String uri) throws SOAPException {
  +        SOAPHeaderElement child = new SOAPHeaderElement(uri,
  +                                                  localName);
  +        child.setPrefix(prefix);
  +        child.addNamespaceDeclaration(prefix, uri);
  +        addChild(child);
  +        child.setEnvelope(getEnvelope());
  +        return child;
  +    }
   }
  
  
  

Mime
View raw message