axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ashut...@apache.org
Subject svn commit: r225703 - in /webservices/axis/trunk/java/modules/saaj: src/org/apache/axis2/saaj/ test/org/apache/axis2/saaj/
Date Thu, 28 Jul 2005 05:43:41 GMT
Author: ashutosh
Date: Wed Jul 27 22:43:24 2005
New Revision: 225703

URL: http://svn.apache.org/viewcvs?rev=225703&view=rev
Log:
Some more test cases on SAAJ envelope, fault, attributes and Text and fixes

Added:
    webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java
    webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TextTest.java
Modified:
    webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java
    webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
    webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
    webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
    webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
    webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java

Modified: webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java?rev=225703&r1=225702&r2=225703&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java
(original)
+++ webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/DetailEntryImpl.java
Wed Jul 27 22:43:24 2005
@@ -43,6 +43,7 @@
      * @param detailEntry
      */
     public DetailEntryImpl(org.apache.axis2.om.OMElement detailEntry) {
+    	super(detailEntry);
         this.detailEntry = detailEntry;
     }
 

Modified: webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java?rev=225703&r1=225702&r2=225703&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java (original)
+++ webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java Wed
Jul 27 22:43:24 2005
@@ -63,10 +63,9 @@
     public SOAPFault addFault() throws SOAPException {
         try {
             //OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor,
will use that
-            SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+            SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
             org.apache.axis2.soap.SOAPFault omSoapFault = soapFactory.createSOAPFault(
-                    omSOAPBody,
-                    new Exception("No explicit faultstring available"));
+                    omSOAPBody);
             omSOAPBody.addFault(omSoapFault);
             return (new SOAPFaultImpl(omSoapFault));
         } catch (Exception e) {

Modified: webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java?rev=225703&r1=225702&r2=225703&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
(original)
+++ webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
Wed Jul 27 22:43:24 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.axis2.saaj;
 
+import org.apache.axis2.om.OMNamespace;
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.NodeList;
@@ -198,6 +199,7 @@
             throws SOAPException {
         org.apache.axis2.om.OMNamespace omNS = org.apache.axis2.om.OMAbstractFactory.getOMFactory()
                 .createOMNamespace(name.getURI(), name.getPrefix());
+        omElement.declareNamespace(omNS);
         //TODO:
         //The namespace of the attribute must be within the scope of the SOAPElement
         //That check should be performed here.
@@ -250,9 +252,13 @@
             Object o = attrIter.next();
             if (o instanceof org.apache.axis2.om.OMAttribute) {
                 //we need to create a SOAPNode for this and add to the arrayList
-                javax.xml.soap.Node soapNode = new NodeImpl(
+                /*javax.xml.soap.Node soapNode = new NodeImpl(
                         (org.apache.axis2.om.OMAttribute) o);
-                arrayList.add(soapNode);
+                arrayList.add(soapNode);*/
+            	//We need to return javax.xml.soap.Name 
+                OMNamespace ons = ((org.apache.axis2.om.OMAttribute)o).getNamespace();
+                String lName = ((org.apache.axis2.om.OMAttribute)o).getLocalName();
+                arrayList.add(new PrefixedQName(ons.getName(), lName, ons.getPrefix()));
             }
         }
         return arrayList.iterator();

Modified: webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java?rev=225703&r1=225702&r2=225703&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
(original)
+++ webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
Wed Jul 27 22:43:24 2005
@@ -67,21 +67,19 @@
         return null;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see javax.xml.soap.SOAPFactory#createName(java.lang.String, java.lang.String, java.lang.String)
      */
     public Name createName(String localName, String prefix, String uri)
             throws SOAPException {
-        // TODO Auto-generated method stub
-        return null;
+        return new PrefixedQName(uri, localName, prefix);
     }
 
-    /* (non-Javadoc)
+    /**
      * @see javax.xml.soap.SOAPFactory#createName(java.lang.String)
      */
     public Name createName(String localName) throws SOAPException {
-        // TODO Auto-generated method stub
-        return null;
+    	return new PrefixedQName(null, localName, null);
     }
 
 }

Modified: webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java?rev=225703&r1=225702&r2=225703&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
(original)
+++ webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPFaultImpl.java
Wed Jul 27 22:43:24 2005
@@ -69,7 +69,7 @@
     public void setFaultCode(String faultCode) throws SOAPException {
         // No direct mapping of SOAP 1.1 faultCode to SOAP 1.2, Mapping it to
         // (Fault Value of FaultCode) in OM impl
-        SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
         SOAPFaultCode fCode = soapFactory.createSOAPFaultCode(fault);
         SOAPFaultValue value = soapFactory.createSOAPFaultValue(fCode);
         fCode.setValue(value);
@@ -98,7 +98,7 @@
     public void setFaultActor(String faultActor) throws SOAPException {
 
         //faultActor mapped to SOAPFaultNode in OM
-        SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
         SOAPFaultNode fNode = soapFactory.createSOAPFaultNode(fault);
         fNode.setNodeValue(faultActor);
     }
@@ -125,7 +125,7 @@
     public void setFaultString(String faultString) throws SOAPException {
 
         //FaultString mapped to text elemtnt of SOAPFaultReason->SOAPFaultText in OM
-        SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
         SOAPFaultReason fReason = soapFactory.createSOAPFaultReason(fault);
         SOAPFaultText text = soapFactory.createSOAPFaultText(fReason);
         text.setText(faultString);
@@ -165,7 +165,7 @@
      */
     public Detail addDetail() throws SOAPException {
 
-        SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
         SOAPFaultDetail detail = soapFactory.createSOAPFaultDetail(fault);
         return new DetailImpl(detail);
     }
@@ -210,7 +210,7 @@
             throws SOAPException {
         //FaultString mapped to text elemtnt of SOAPFaultReason->SOAPFaultText in OM
         // Not using Locale information
-        SOAPFactory soapFactory = OMAbstractFactory.getDefaultSOAPFactory();
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
         SOAPFaultReason fReason = soapFactory.createSOAPFaultReason(fault);
         SOAPFaultText text = soapFactory.createSOAPFaultText(fReason);
         text.setText(faultString);

Modified: webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java?rev=225703&r1=225702&r2=225703&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java (original)
+++ webservices/axis/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java Wed
Jul 27 22:43:24 2005
@@ -88,6 +88,7 @@
             }
 
         } catch (Exception e) {
+        	//e.printStackTrace();
             throw new SOAPException(e);
         }
     }

Added: webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java?rev=225703&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java
(added)
+++ webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/EnvelopeTest.java
Wed Jul 27 22:43:24 2005
@@ -0,0 +1,263 @@
+package org.apache.axis2.saaj;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.Name;
+import javax.xml.soap.Node;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.soap.Text;
+
+import junit.framework.TestCase;
+import junit.framework.AssertionFailedError;
+
+public class EnvelopeTest extends TestCase {
+	
+    public EnvelopeTest(String name) {
+        super(name);
+    }
+
+    String xmlString =
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+        "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"
+
+        "                   xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" +
+        "                   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"
+
+        " <soapenv:Header>\n" +
+        "  <shw:Hello xmlns:shw=\"http://www.jcommerce.net/soap/ns/SOAPHelloWorld\">\n"
+
+        "    <shw:Myname>Tony</shw:Myname>\n" +
+        "  </shw:Hello>\n" +
+        " </soapenv:Header>\n" +
+        " <soapenv:Body>\n" +
+        "  <shw:Address xmlns:shw=\"http://www.jcommerce.net/soap/ns/SOAPHelloWorld\">\n"
+
+        "    <shw:City>GENT</shw:City>\n" +
+        "  </shw:Address>\n" +
+        " </soapenv:Body>\n" +
+        "</soapenv:Envelope>";
+    
+   public void testEnvelope() throws Exception{
+    	MessageFactory mf = MessageFactory.newInstance();
+    	SOAPMessage smsg = 
+    		mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
+    	SOAPPart sp = smsg.getSOAPPart();
+    	SOAPEnvelope se = (SOAPEnvelope)sp.getEnvelope();
+    	//smsg.writeTo(System.out);
+    	assertTrue(se != null);
+    }
+    
+    public void testEnvelope2() throws Exception{
+    	MessageFactory mf = MessageFactory.newInstance();
+    	SOAPMessage smsg =
+    		mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
+    	SOAPPart sp = smsg.getSOAPPart();
+    	SOAPEnvelope se = (SOAPEnvelope)sp.getEnvelope();
+    	ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    	smsg.writeTo(baos);
+    	SOAPBody body = smsg.getSOAPPart().getEnvelope().getBody();
+    	assertTrue(body != null);
+    }
+    /*
+     * Commenting out for now, as  underlying StaxSOAPModelBuilder does not have
+     * capability to process comments
+     * 
+    public void testEnvelopeWithLeadingComment() throws Exception {
+    	String soapMessageWithLeadingComment =
+    		"<?xml version='1.0' encoding='UTF-8'?>" + 
+    		"<!-- Comment -->" +
+			"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
+			"<env:Body><echo><arg0>Hello</arg0></echo></env:Body>"
+
+			"</env:Envelope>";
+    	
+    	SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
+    	SOAPConnection con = scFactory.createConnection();
+    	
+    	MessageFactory factory = MessageFactory.newInstance();
+    	SOAPMessage message =
+    		factory.createMessage(new MimeHeaders(),
+    				new ByteArrayInputStream(soapMessageWithLeadingComment.getBytes()));
+    	SOAPPart part = message.getSOAPPart();
+    	SOAPEnvelope envelope = (SOAPEnvelope) part.getEnvelope();
+    	message.writeTo(System.out);
+    	assertTrue(envelope != null);
+    }
+    */
+    
+    private SOAPEnvelope getSOAPEnvelope() throws Exception {
+        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
+        SOAPConnection con = scFactory.createConnection();
+
+        MessageFactory factory = MessageFactory.newInstance();
+        SOAPMessage message = factory.createMessage();
+        SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
+        return envelope;
+    }
+    
+    public void testFaults() throws Exception {
+        SOAPEnvelope envelope = getSOAPEnvelope();
+        SOAPBody body = envelope.getBody();
+        SOAPFault sf = body.addFault();
+        //sf.setFaultCode("myFault");
+        //String fc = sf.getFaultCode();
+        sf.setFaultString("myFault");
+        String fc = sf.getFaultString(); //Chk the same for FaultCode as well
+        							// currently not done in SAAJ
+        assertTrue(fc.equals("myFault"));
+    }
+    
+    private int getIteratorCount(java.util.Iterator i) {
+        int count = 0;
+        while (i.hasNext()) {
+            count++;
+            i.next();
+        }
+        return count;
+    }
+    
+    public void testFaults2() throws Exception {
+    
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPFault sf = body.addFault();
+    	
+    	assertTrue(body.getFault() != null);
+    	
+    	Detail d1 = sf.addDetail();
+    	Name name = envelope.createName("GetLastTradePrice", "WOMBAT",
+    	"http://www.wombat.org/trader");
+    	d1.addDetailEntry(name);
+    	
+    	Detail d2 = sf.getDetail();
+    	assertTrue(d2 != null);
+    	Iterator i = d2.getDetailEntries();
+    	assertTrue(getIteratorCount(i) == 1);
+    	i = d2.getDetailEntries();
+    	//message.writeTo(System.out);
+    	while(i.hasNext()) {
+    		DetailEntry de = (DetailEntry)i.next();
+    		assertEquals(de.getElementName(),name);
+    	}
+    }
+    
+    public void testHeaderElements() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPHeader hdr = envelope.getHeader();
+    	
+    	SOAPHeaderElement she1 = hdr.addHeaderElement(envelope.createName("foo1", "f1", "foo1-URI"));
+    	she1.setActor("actor-URI");
+    	java.util.Iterator iterator = hdr.extractHeaderElements("actor-URI");
+    	int cnt = 0;
+    	while (iterator.hasNext()) {
+    		cnt++;
+    		SOAPHeaderElement she = (SOAPHeaderElement) iterator.next();
+    		assertTrue(she.equals(she1));
+    	}
+    	assertTrue(cnt == 1);
+    	iterator = hdr.extractHeaderElements("actor-URI");
+    	assertTrue(!iterator.hasNext());
+    }
+    
+    public void testText1() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+     	Iterator iStart = body.getChildElements();
+    	int countStart = getIteratorCount(iStart);
+    	SOAPElement se = body.addTextNode("<txt>This is text</txt>");
+    	assertTrue(se != null);
+    	assertTrue(body.getValue().equals("<txt>This is text</txt>"));
+    	Iterator i = body.getChildElements();
+    	int count = getIteratorCount(i);
+    	assertTrue(count == countStart + 1);
+    }
+    
+    public void testText2() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPElement se = body.addTextNode("This is text");
+    	Iterator iterator = se.getChildElements();
+    	Node n = null;
+    	while (iterator.hasNext()) {
+    		n = (Node)iterator.next();
+    		if (n instanceof Text){
+    			break;
+    		}
+    	}
+    	assertTrue(n instanceof Text);
+    	Text t = (Text)n;
+    	assertTrue(!t.isComment());
+    }
+    
+    public void testText3() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	SOAPElement se = body.addTextNode("<!-- This is a comment -->");
+    	Iterator iterator = se.getChildElements();
+    	Node n = null;
+    	while (iterator.hasNext()) {
+    		n = (Node)iterator.next();
+    		if (n instanceof Text)
+    			break;
+    	}
+    	assertTrue(n instanceof Text);
+    	Text t = (Text)n;
+    	assertTrue(t.isComment());
+    }
+    
+    public void testAttributes() throws Exception {
+    	SOAPEnvelope envelope = getSOAPEnvelope();
+    	SOAPBody body = envelope.getBody();
+    	
+    	Name name1 = envelope.createName("MyAttr1");
+    	String value1 = "MyValue1";
+    	Name name2 = envelope.createName("MyAttr2");
+    	String value2 = "MyValue2";
+    	Name name3 = envelope.createName("MyAttr3");
+    	String value3 = "MyValue3";
+    	body.addAttribute(name1, value1);
+    	body.addAttribute(name2, value2);
+    	body.addAttribute(name3, value3);
+    	java.util.Iterator iterator = body.getAllAttributes();
+    	assertTrue(getIteratorCount(iterator) == 3);
+    	iterator = body.getAllAttributes();
+    	boolean foundName1 = false;
+    	boolean foundName2 = false;
+    	boolean foundName3 = false;
+    	while (iterator.hasNext()) {
+    		Name name = (Name) iterator.next();
+    		if (name.equals(name1))
+    			foundName1 = true;
+    		else if (name.equals(name2))
+    			foundName2 = true;
+    		else if (name.equals(name3))
+    			foundName3 = true;
+    	}
+    }
+    
+    public static void main(String[] args) throws Exception {
+    	EnvelopeTest tester = new EnvelopeTest("EnvelopeTest");
+    	tester.testEnvelope();
+    	tester.testEnvelope2();
+    	tester.testFaults();
+    	tester.testFaults2();
+    	tester.testHeaderElements();
+    	tester.testText1();
+    	tester.testText2();
+    	tester.testText3();
+    	tester.testAttributes();
+    }
+}

Added: webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TextTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TextTest.java?rev=225703&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TextTest.java (added)
+++ webservices/axis/trunk/java/modules/saaj/test/org/apache/axis2/saaj/TextTest.java Wed
Jul 27 22:43:24 2005
@@ -0,0 +1,134 @@
+package org.apache.axis2.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBodyElement;
+
+public class TextTest extends TestCase {
+	
+	public TextTest(String name){
+		super(name);
+	}
+	
+	//Test SAAJ addTextNode performance
+	public void testAddTextNode() throws Exception {
+        SOAPFactory soapFactory = SOAPFactory.newInstance();
+        MessageFactory factory = MessageFactory.newInstance();
+        SOAPMessage message = factory.createMessage();
+        SOAPHeader header = message.getSOAPHeader();
+        SOAPBody body = message.getSOAPBody();
+        
+        // Create the base element
+        Name bodyName = soapFactory.createName("VBGenReceiver", "xsi",
+                "http://www.w3.org/2001/XMLSchema-instance");
+        SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
+        
+        // Create the MetaData Tag
+        Name name = soapFactory.createName("MetaData");
+        SOAPElement metaData = bodyElement.addChildElement(name);
+
+        //Create the SKey Tag
+        name = soapFactory.createName("SKey");
+        SOAPElement sKey = metaData.addChildElement(name);
+        sKey.addTextNode("SKEY001");
+
+        //Create Object Tag
+        name = soapFactory.createName("Object");
+        SOAPElement object = bodyElement.addChildElement(name);
+
+        //Create Book ID Tag
+        name = soapFactory.createName("BookID");
+        SOAPElement bookID = object.addChildElement(name);
+        bookID.addTextNode("BookID002");
+
+        //Create OrderID tag
+        name = soapFactory.createName("OrderID");
+        SOAPElement orderID = object.addChildElement(name);
+        orderID.addTextNode("OrderID003");
+
+        //create PurchaseID tage
+        name = soapFactory.createName("PurchaseID");
+        SOAPElement purchaseID = object.addChildElement(name);
+        purchaseID.addTextNode("PurchaseID005");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("LanguageID");
+        SOAPElement languageID = object.addChildElement(name);
+        languageID.addTextNode("LanguageID004");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("LanguageName");
+        SOAPElement languageName = object.addChildElement(name);
+        languageName.addTextNode("LanguageName006");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Title");
+        SOAPElement title = object.addChildElement(name);
+        title.addTextNode("Title007");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Author");
+        SOAPElement author = object.addChildElement(name);
+        author.addTextNode("Author008");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Format");
+        SOAPElement format = bodyElement.addChildElement(name);
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Type");
+        SOAPElement formatType = format.addChildElement(name);
+        formatType.addTextNode("Type009");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Delivery");
+        SOAPElement delivery = bodyElement.addChildElement(name);
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Name");
+        SOAPElement delName = delivery.addChildElement(name);
+        delName.addTextNode("Name010");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Address1");
+        SOAPElement address1 = delivery.addChildElement(name);
+        address1.addTextNode("Address1011");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("Address2");
+        SOAPElement address2 = delivery.addChildElement(name);
+        address2.addTextNode("Address2012");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("City");
+        SOAPElement city = delivery.addChildElement(name);
+        city.addTextNode("City013");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("State");
+        SOAPElement state = delivery.addChildElement(name);
+        state.addTextNode("State014");
+
+        //create LanguageID Tag
+        name = soapFactory.createName("PostalCode");
+        SOAPElement postalCode = delivery.addChildElement(name);
+        postalCode.addTextNode("PostalCode015");
+
+        System.out.println("The message is lll:\n");
+        message.writeTo(System.out);
+
+	}
+
+    public static void main(String[] args) throws Exception {
+        TextTest tester = new TextTest("TestEnvelope");
+        tester.testAddTextNode();
+    }
+	
+}



Mime
View raw message