You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ve...@apache.org on 2005/04/13 08:43:07 UTC
svn commit: r161159 [1/2] - in
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj: ./ bin/
src/java/javax/xml/soap/ src/java/org/apache/axis/saaj/
src/java/org/apache/axis/util/ src/test/org/apache/axis/saaj/
Author: venkat
Date: Tue Apr 12 23:43:02 2005
New Revision: 161159
URL: http://svn.apache.org/viewcvs?view=rev&rev=161159
Log:
Adding files for SAAJ implementation over OM - from Ashutosh.
Added:
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.project
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/bin/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MimeHeaders.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeListImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPDocumentImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/TextImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/IOUtils.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/SessionUtils.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/XMLUtils.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/test/org/apache/axis/saaj/TestClient2.java
Modified:
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/MessageFactory.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPConnectionFactory.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/DetailImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPBodyImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPElementImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPEnvelopeImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFaultImpl.java
webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPHeaderImpl.java
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.classpath Tue Apr 12 23:43:02 2005
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/stax-api-1.0.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-core-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-deployment-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-http-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-mail-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-om-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-Samples-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-Tools-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/axis2-wsdl-M1.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/commons-fileupload-1.0.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/commons-logging-1.0.3.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/log4j-1.2.8.jar"/>
+ <classpathentry kind="lib" path="C:/tomcat5/webapps/axis2/WEB-INF/lib/stax-1.1.1-dev.jar"/>
+ <classpathentry kind="lib" path="C:/Apache/ws-axis/java/lib/mailapi_1_3_1.jar"/>
+ <classpathentry kind="lib" path="C:/Apache/ws-axis/java/lib/activation.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.project
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.project?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.project (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/.project Tue Apr 12 23:43:02 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Saaj4Axis2</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/readme.txt Tue Apr 12 23:43:02 2005
@@ -1,11 +1,14 @@
+Dt. 23 March 2005
-SAAJ for OM
-============
-
-The objective is to provide a SAAJ implementation layer over the OM. Source for SAAJ interfaces are taken from Axis 1.2. The implementation of these interfaces using the OM specific classes is in org.apache.axis.saaj package.
-
-The implementation is not complete yet and supports only construction of a basic soap message and the operations related to it. The implementation is linked to OM implementation and likely to change when the OM implementation is changed.
+The following implementation provides a SAAJ wrapper on the OM implementation of SOAP. SAAJ
+specific interfaces are present in javax.xml.soap package and have been taken from Axis 1.2
+implementation. The implementation of these interfaces using the OM specific classes (thereby
+providing a SAAJ wrapper on OM) is in org.apache.axis.saaj package.
+
+The implementation is not complete yet and supports only construction of a basic soap message
+and the operations related to it. The implementation is linked to OM implementation and likely
+to change when the OM implementation is changed.
A test client is provided to demonstrate creating a basic soap message and sending it to the server.
-
+Ashutosh Shahi
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/MessageFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/MessageFactory.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/MessageFactory.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/MessageFactory.java Tue Apr 12 23:43:02 2005
@@ -162,7 +162,7 @@
throws IOException, SOAPException;
private static final String DEFAULT_MESSAGE_FACTORY =
- "org.apache.axis.soap.MessageFactoryImpl";
+ "org.apache.axis.saaj.MessageFactoryImpl";
private static final String MESSAGE_FACTORY_PROPERTY =
"javax.xml.soap.MessageFactory";
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPConnectionFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPConnectionFactory.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPConnectionFactory.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/javax/xml/soap/SOAPConnectionFactory.java Tue Apr 12 23:43:02 2005
@@ -58,7 +58,7 @@
public abstract SOAPConnection createConnection() throws SOAPException;
private static final String DEFAULT_SOAP_CONNECTION_FACTORY =
- "org.apache.axis.soap.SOAPConnectionFactoryImpl";
+ "org.apache.axis.saaj.SOAPConnectionFactoryImpl";
private static final String SF_PROPERTY =
"javax.xml.soap.SOAPConnectionFactory";
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/DetailImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/DetailImpl.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/DetailImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/DetailImpl.java Tue Apr 12 23:43:02 2005
@@ -13,8 +13,8 @@
import javax.xml.soap.SOAPException;
import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.impl.llom.OMElementImpl;
/**
* Class DetailImpl
@@ -36,7 +36,8 @@
* @param parent
*/
public DetailImpl(javax.xml.namespace.QName detailName, OMElement parent){
- detail = new OMElementImpl(detailName, parent);
+ OMFactory omFactory = OMFactory.newInstance();
+ detail = omFactory.createOMElement(detailName, parent);
}
/*public DetailImpl(OMElement detail){
@@ -57,10 +58,11 @@
// May need change after OM allows adding multiple detailEntries
// as then we can delegate the task there rather than dealing with OMElement here
String localName = name.getLocalName();
- OMNamespace ns = new org.apache.axis.om.impl.llom.OMNamespaceImpl(name.getURI(), name.getPrefix());
- OMElement detailEntry = new org.apache.axis.om.impl.llom.OMElementImpl(localName, ns);
+ OMFactory omFactory = OMFactory.newInstance();
+ OMNamespace ns = omFactory.createOMNamespace(name.getURI(), name.getPrefix());
+ OMElement detailEntry = omFactory.createOMElement(localName, ns);
detail.addChild(detailEntry);
- return (DetailEntry)(new DetailEntryImpl(detailEntry));
+ return (new DetailEntryImpl(detailEntry));
}
/**
@@ -71,7 +73,7 @@
*/
protected DetailEntry addDetailEntry(org.apache.axis.om.OMNode detailEntry){
detail.addChild(detailEntry);
- return (DetailEntry)(new DetailEntryImpl((OMElement)detailEntry));
+ return (new DetailEntryImpl((OMElement)detailEntry));
}
/**
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MessageFactoryImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,43 @@
+/*
+ * Created on Apr 8, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+/**
+ * @author shaas02
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class MessageFactoryImpl extends MessageFactory {
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.MessageFactory#createMessage()
+ */
+ public SOAPMessage createMessage() throws SOAPException {
+ SOAPEnvelopeImpl env = new SOAPEnvelopeImpl();
+ SOAPMessageImpl message = new SOAPMessageImpl(env);
+ return message;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.MessageFactory#createMessage(javax.xml.soap.MimeHeaders, java.io.InputStream)
+ */
+ public SOAPMessage createMessage(MimeHeaders mimeheaders,
+ InputStream inputstream) throws IOException, SOAPException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MimeHeaders.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MimeHeaders.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MimeHeaders.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/MimeHeaders.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,39 @@
+/*
+ * Created on Apr 8, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import java.util.Iterator;
+import javax.xml.soap.MimeHeader;
+
+/**
+ * @author shaas02
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class MimeHeaders extends javax.xml.soap.MimeHeaders {
+ public MimeHeaders() {
+ }
+
+ public MimeHeaders(javax.xml.soap.MimeHeaders h) {
+ Iterator iterator = h.getAllHeaders();
+ while (iterator.hasNext()) {
+ MimeHeader hdr = (MimeHeader) iterator.next();
+ addHeader(hdr.getName(), hdr.getValue());
+ }
+ }
+
+ private int getHeaderSize() {
+ int size = 0;
+ Iterator iterator = getAllHeaders();
+ while (iterator.hasNext()) {
+ iterator.next();
+ size++;
+ }
+ return size;
+ }
+}
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeImpl.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeImpl.java Tue Apr 12 23:43:02 2005
@@ -18,6 +18,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
+import org.w3c.dom.CharacterData;
/**
* Class NodeImpl
@@ -30,18 +31,20 @@
/**
* Field omNode
*/
- private org.apache.axis.om.OMNode omNode;
+ protected org.apache.axis.om.OMNode omNode;
/**
* field document
*/
- private org.w3c.dom.Document document;
+ protected org.w3c.dom.Document document;
+
+ //protected CharacterData textRep = null;
/**
* Constructor NodeImpl
*
*/
public NodeImpl(){
-
+
}
/**
@@ -75,7 +78,15 @@
// Find out a way to construct OMNode from OMNamespace
// OMNamespace is immutable
}
-
+
+ /**
+ * constructor which adopts the name and NS of the char data, and its text
+ * @param text
+ */
+/* public NodeImpl(CharacterData text) {
+
+ }
+*/
/**
* Method getValue
*
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeListImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeListImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeListImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/NodeListImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,69 @@
+/*
+ * Created on Apr 11, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.List;
+import java.util.Collections;
+import java.util.ArrayList;
+
+/**
+ * @author shaas02
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class NodeListImpl implements NodeList {
+
+ List mNodes;
+
+ public static final NodeList EMPTY_NODELIST = new NodeListImpl(Collections.EMPTY_LIST);
+
+ /**
+ * Constructor and Setter is intensionally made package access only.
+ *
+ */
+ NodeListImpl() {
+ mNodes = new ArrayList();
+ }
+
+ NodeListImpl(List nodes) {
+ this();
+ mNodes.addAll(nodes);
+ }
+
+ void addNode(org.w3c.dom.Node node) {
+ mNodes.add(node);
+ }
+
+ void addNodeList(org.w3c.dom.NodeList nodes) {
+ for (int i = 0; i < nodes.getLength(); i++) {
+ mNodes.add(nodes.item(i));
+ }
+ }
+
+ /**
+ * Interface Implemented
+ *
+ * @param index
+ * @return
+ */
+ public Node item(int index) {
+ if (mNodes != null && mNodes.size() > index) {
+ return (Node) mNodes.get(index);
+ } else {
+ return null;
+ }
+ }
+
+ public int getLength() {
+ return mNodes.size();
+ }
+
+}
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPBodyImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPBodyImpl.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPBodyImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPBodyImpl.java Tue Apr 12 23:43:02 2005
@@ -17,7 +17,7 @@
import org.w3c.dom.Document;
import org.apache.axis.om.OMElement;
-import org.apache.axis.om.impl.llom.OMElementImpl;
+import org.apache.axis.om.OMFactory;
import javax.xml.namespace.QName;
@@ -53,9 +53,10 @@
public SOAPFault addFault() throws SOAPException {
try{
//OM SOAPFaultImpl has SOAPFaultImpl(OMElement parent, Exception e) constructor, will use that
- org.apache.axis.om.SOAPFault omSoapFault = new org.apache.axis.om.impl.llom.SOAPFaultImpl(omSOAPBody, new Exception("No explicit faultstring available"));
+ OMFactory omFactory = OMFactory.newInstance();
+ org.apache.axis.om.SOAPFault omSoapFault = omFactory.createSOAPFault(omSOAPBody, new Exception("No explicit faultstring available"));
omSOAPBody.addFault(omSoapFault);
- return (SOAPFault)(new SOAPFaultImpl(omSoapFault));
+ return (new SOAPFaultImpl(omSoapFault));
}catch(Exception e)
{
throw new SOAPException(e);
@@ -77,7 +78,7 @@
* @return
*/
public SOAPFault getFault() {
- return (SOAPFault)(new SOAPFaultImpl(omSOAPBody.getFault()));
+ return (new SOAPFaultImpl(omSOAPBody.getFault()));
}
/**
@@ -90,11 +91,11 @@
public SOAPBodyElement addBodyElement(Name name) throws SOAPException {
try {
- //QName qname = new QName(name.getURI(), name.getLocalName());
+ OMFactory omFactory = OMFactory.newInstance();
QName qname = new QName(name.getURI(), name.getLocalName(), name.getPrefix());
- OMElement bodyElement = new OMElementImpl(qname, omSOAPBody);
+ OMElement bodyElement = omFactory.createOMElement(qname, omSOAPBody);
omSOAPBody.addChild(bodyElement);
- return (SOAPBodyElement)(new SOAPBodyElementImpl(bodyElement));
+ return (new SOAPBodyElementImpl(bodyElement));
} catch (Exception e)
{
throw new SOAPException(e);
@@ -117,9 +118,10 @@
//a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
//So am deferring it.
//even locale param is dropped, don't know how to handle it at the moment. so dropped it.
- org.apache.axis.om.SOAPFault omSoapFault = new org.apache.axis.om.impl.llom.SOAPFaultImpl(omSOAPBody, new Exception(faultString));
+ OMFactory omFactory = OMFactory.newInstance();
+ org.apache.axis.om.SOAPFault omSoapFault = omFactory.createSOAPFault(omSOAPBody, new Exception(faultString));
omSOAPBody.addFault(omSoapFault);
- return (SOAPFault)(new SOAPFaultImpl(omSoapFault));
+ return (new SOAPFaultImpl(omSoapFault));
}catch(Exception e)
{
throw new SOAPException(e);
@@ -141,9 +143,10 @@
//actually soap fault is created with the OM's default SOAPFAULT_LOCALNAME and PREFIX, b'coz I've droppe the name param
//a work around can be possible but would be confusing as there is no straight forward soapfault constructor in om.
//So am deferring it.
- org.apache.axis.om.SOAPFault omSoapFault = new org.apache.axis.om.impl.llom.SOAPFaultImpl(omSOAPBody, new Exception(faultString));
+ OMFactory omFactory = OMFactory.newInstance();
+ org.apache.axis.om.SOAPFault omSoapFault = omFactory.createSOAPFault(omSOAPBody, new Exception(faultString));
omSOAPBody.addFault(omSoapFault);
- return (SOAPFault)(new SOAPFaultImpl(omSoapFault));
+ return (new SOAPFaultImpl(omSoapFault));
}catch(Exception e)
{
throw new SOAPException(e);
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionFactoryImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,32 @@
+/*
+ * Created on Mar 23, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPException;
+
+/**
+ * Class SOAPConnectionFactoryImpl
+ *
+ * @author Ashutosh Shahi
+ * ashutosh.shahi@gmail.com
+ */
+public class SOAPConnectionFactoryImpl extends SOAPConnectionFactory {
+
+ /**
+ * Create a new <CODE>SOAPConnection</CODE>.
+ * @return the new <CODE>SOAPConnection</CODE> object.
+ * @throws SOAPException if there was an exception
+ * creating the <CODE>SOAPConnection</CODE> object.
+ */
+ public SOAPConnection createConnection() throws SOAPException {
+
+ return new SOAPConnectionImpl();
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPConnectionImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,61 @@
+/*
+ * Created on Mar 23, 2005
+ *
+ */
+package org.apache.axis.saaj;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPEnvelope;
+
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.Call;
+import org.apache.axis.engine.AxisFault;
+
+
+/**
+ * Class SOAPConnectionImpl
+ *
+ * @author Ashutosh Shahi (ashutosh.shahi@gmail.com)
+ *
+ */
+public class SOAPConnectionImpl extends SOAPConnection {
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPConnection#call(javax.xml.soap.SOAPMessage, java.lang.Object)
+ */
+ public SOAPMessage call(SOAPMessage request, Object endpoint)
+ throws SOAPException {
+ try{
+ org.apache.axis.om.SOAPEnvelope envelope = ((SOAPEnvelopeImpl)request.getSOAPPart().getEnvelope()).getOMEnvelope();
+
+ Call call = new Call();
+ URL url = new URL(endpoint.toString());
+ call.setListenerTransport("http", true);
+ call.setTo(new EndpointReference(AddressingConstants.WSA_TO, url.toString()));
+ org.apache.axis.om.SOAPEnvelope responseEnv = call.sendReceive(envelope);
+ SOAPEnvelopeImpl response = new SOAPEnvelopeImpl(responseEnv);
+ return new SOAPMessageImpl(response);
+
+ }catch (MalformedURLException mue) {
+ throw new SOAPException(mue);
+ }catch (AxisFault af){
+ throw new SOAPException(af);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPConnection#close()
+ */
+ public void close() throws SOAPException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPDocumentImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPDocumentImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPDocumentImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPDocumentImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,402 @@
+/*
+ * Created on Apr 11, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+
+import org.apache.axis.util.XMLUtils;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.soap.SOAPException;
+
+/**
+ * @author shaas02
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SOAPDocumentImpl implements Document {
+
+ // Depending on the user's parser preference
+ protected Document delegate = null;
+ protected SOAPPartImpl soapPart = null;
+
+ /**
+ * Construct the Document
+ *
+ * @param sp the soap part
+ */
+ public SOAPDocumentImpl(SOAPPartImpl sp) {
+ try {
+ delegate = XMLUtils.newDocument();
+ } catch (ParserConfigurationException e) {
+ // Do nothing
+ }
+ soapPart = sp;
+ }
+
+ public DOMImplementation getImplementation() {
+ return delegate.getImplementation();
+ }
+
+ /**
+ *
+ * Creates an empty <code>DocumentFragment</code> object. @todo not
+ * implemented yet
+ *
+ * @return A new <code>DocumentFragment</code>.
+ */
+ public DocumentFragment createDocumentFragment() {
+ return delegate.createDocumentFragment();
+ }
+
+ /**
+ * @todo : link with SOAP
+ *
+ * @return
+ */
+ public DocumentType getDoctype() {
+ return delegate.getDoctype();
+ }
+
+ /**
+ * should not be called, the method will be handled in SOAPPart
+ *
+ * @return
+ */
+ public Element getDocumentElement() {
+ return soapPart.getDocumentElement();
+ }
+
+ /**
+ * @todo: How Axis will maintain the Attribute representation ?
+ */
+ public Attr createAttribute(String name) throws DOMException {
+ return delegate.createAttribute(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createCDATASection(java.lang.String)
+ */
+ public CDATASection createCDATASection(String arg0) throws DOMException {
+ // Not implementing this one, as it may not be supported in om
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createComment(java.lang.String)
+ */
+ public Comment createComment(String arg0) {
+ //Not implementing this one, as it may not be supported in om
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createElement(java.lang.String)
+ */
+ public Element createElement(String arg0) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Element getElementById(String elementId) {
+ return delegate.getElementById(elementId);
+ }
+
+
+ /**
+ * @param name
+ * @return @throws
+ * DOMException
+ */
+ public EntityReference createEntityReference(String name)
+ throws DOMException {
+ throw new java.lang.UnsupportedOperationException(
+ "createEntityReference");
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#importNode(org.w3c.dom.Node, boolean)
+ */
+ public Node importNode(Node arg0, boolean arg1) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#getElementsByTagName(java.lang.String)
+ */
+ public NodeList getElementsByTagName(String localName) {
+ try{
+ NodeListImpl list = new NodeListImpl();
+ if (soapPart != null) {
+ SOAPEnvelopeImpl soapEnv = (SOAPEnvelopeImpl)soapPart.getEnvelope();
+ SOAPHeaderImpl header = (SOAPHeaderImpl)soapEnv.getHeader();
+ if (header != null) {
+ list.addNodeList(header.getElementsByTagName(localName));
+ }
+ SOAPBodyImpl body = (SOAPBodyImpl)soapEnv.getBody();
+ if (body != null) {
+ list.addNodeList(body.getElementsByTagName(localName));
+ }
+ }
+ return list;
+ }catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createTextNode(java.lang.String)
+ */
+ public Text createTextNode(String data) {
+ TextImpl me = new TextImpl(delegate.createTextNode(data));
+ me.setOwnerDocument(soapPart);
+ return me;
+ }
+
+ /**
+ * Attribute is not particularly dealt with in SAAJ.
+ *
+ */
+ public Attr createAttributeNS(String namespaceURI, String qualifiedName)
+ throws DOMException {
+ return delegate.createAttributeNS(namespaceURI, qualifiedName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#createElementNS(java.lang.String, java.lang.String)
+ */
+ public Element createElementNS(String arg0, String arg1)
+ throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.w3c.dom.Document#getElementsByTagNameNS(java.lang.String, java.lang.String)
+ */
+ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+ try{
+ NodeListImpl list = new NodeListImpl();
+ if (soapPart != null) {
+ SOAPEnvelopeImpl soapEnv = (SOAPEnvelopeImpl)soapPart.getEnvelope();
+ SOAPHeaderImpl header = (SOAPHeaderImpl)soapEnv.getHeader();
+ if (header != null) {
+ list.addNodeList(header.getElementsByTagNameNS(namespaceURI, localName));
+ }
+ SOAPBodyImpl body = (SOAPBodyImpl)soapEnv.getBody();
+ if (body != null) {
+ list.addNodeList(body.getElementsByTagNameNS(namespaceURI, localName));
+ }
+ }
+ return list;
+ }catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+
+ public ProcessingInstruction createProcessingInstruction(
+ String target,
+ String data)
+ throws DOMException {
+ throw new java.lang.UnsupportedOperationException(
+ "createProcessingInstruction");
+ }
+
+
+ /**
+ * override it in sub-classes
+ *
+ * @return
+ */
+ public short getNodeType() {
+ return Node.DOCUMENT_NODE;
+ }
+
+
+ public void normalize() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+ public boolean hasAttributes() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public boolean hasChildNodes() {
+ try {
+ if (soapPart != null) {
+ if (soapPart.getEnvelope() != null) {
+ return true;
+ }
+ }
+ return false;
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public String getLocalName() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public String getNamespaceURI() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+ public String getNodeName() {
+ return null;
+ }
+
+ public String getNodeValue() throws DOMException {
+ throw new DOMException(
+ DOMException.NO_DATA_ALLOWED_ERR,
+ "Cannot use TextNode.get in " + this);
+ }
+
+ public String getPrefix() {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public void setNodeValue(String nodeValue) throws DOMException {
+ throw new DOMException(
+ DOMException.NO_DATA_ALLOWED_ERR,
+ "Cannot use TextNode.set in " + this);
+ }
+
+
+ public void setPrefix(String prefix) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ /**
+ *
+ * we have to have a link to them...
+ */
+ public Document getOwnerDocument() {
+ return null;
+ }
+
+ public NamedNodeMap getAttributes() {
+ return null;
+ }
+
+ public Node getFirstChild() {
+ try {
+ if (soapPart != null)
+ return (org.apache.axis.saaj.SOAPEnvelopeImpl) soapPart
+ .getEnvelope();
+ else
+ return null;
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public Node getLastChild() {
+ try {
+ if (soapPart != null)
+ return (org.apache.axis.saaj.SOAPEnvelopeImpl) soapPart
+ .getEnvelope();
+ else
+ return null;
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public Node getNextSibling() {
+
+ return null;
+ }
+
+ public Node getParentNode() {
+ return null;
+ }
+
+ public Node getPreviousSibling() {
+ return null;
+ }
+
+ public Node cloneNode(boolean deep) {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+ public NodeList getChildNodes() {
+ try {
+ if (soapPart != null) {
+ NodeListImpl children = new NodeListImpl();
+ children.addNode(soapPart.getEnvelope());
+ return children;
+ } else {
+ return NodeListImpl.EMPTY_NODELIST;
+ }
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+
+ }
+
+ // fill appropriate features
+ private String[] features = { "foo", "bar" };
+ private String version = "version 2.0";
+
+ public boolean isSupported(String feature, String version) {
+ if (!version.equalsIgnoreCase(version))
+ return false;
+ else
+ return true;
+ }
+
+ public Node appendChild(Node newChild) throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public Node removeChild(Node oldChild) throws DOMException {
+ try {
+ Node envNode;
+ if (soapPart != null) {
+ envNode = soapPart.getEnvelope();
+ if (envNode.equals(oldChild)) {
+ return envNode;
+ }
+ }
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ } catch (SOAPException se) {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "");
+ }
+ }
+
+ public Node insertBefore(Node newChild, Node refChild)
+ throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+ public Node replaceChild(Node newChild, Node oldChild)
+ throws DOMException {
+ throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "");
+ }
+
+
+}
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPElementImpl.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPElementImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPElementImpl.java Tue Apr 12 23:43:02 2005
@@ -18,35 +18,37 @@
import java.util.ArrayList;
/**
* Class SOAPElementImpl
- *
+ *
* @author Jayachandra
* jayachandra@gmail.com
*/
public class SOAPElementImpl extends NodeImpl implements SOAPElement {
/**
* Field omElement
- * The corresponding OM object for SOAPElement is OMElement, so we would
+ * The corresponding OM object for SOAPElement is OMElement, so we would
* have a datamember of type OMElement in this class
*/
protected org.apache.axis.om.OMElement omElement;
-
+
/**
* Constructor SOAPElementImpl
- * The standard constructor of being able to create soapelement given a omElement
+ * The standard constructor for being able to create SOAPElement given a omElement
* @param omElement
*/
public SOAPElementImpl(org.apache.axis.om.OMElement omElement)
{
+ super(omElement);
this.omElement = omElement;
}
-
+
/**
* Constructor SOAPElementImpl
* The empty constructor
*/
public SOAPElementImpl() {
+ super();
}
-
+
/**
* Method getOMElement
* getter method on the data member omElement
@@ -64,15 +66,15 @@
* @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.Name)
*/
public SOAPElement addChildElement(Name name) throws SOAPException {
- //We will create a new OMElement and add that as a child to the OMElement datamember that
- //we are carrying along. And return back a wrapped SOAPElement corresponding to the
+ //We will create a new OMElement and add that as a child to the OMElement datamember that
+ //we are carrying along. And return back a wrapped SOAPElement corresponding to the
//created OMElement
-
+
//Since a <code>Name</code> object is given as parameter we should try to create an OMElement
- //and register it with the contents of the <code>name</code> element
- org.apache.axis.om.OMElement newOMElement = new org.apache.axis.om.impl.llom.OMElementImpl(new QName(name.getURI(), name.getLocalName(), name.getPrefix()), omElement);
- omElement.addChild(newOMElement);
- return (SOAPElement)(new SOAPElementImpl(newOMElement));
+ //and register it with the contents of the <code>name</code> element
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMFactory.newInstance().createOMElement(new QName(name.getURI(), name.getLocalName(), name.getPrefix()), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
}
/**
@@ -83,12 +85,12 @@
* @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String)
*/
public SOAPElement addChildElement(String localName) throws SOAPException {
- //We will create a new OMElement and add that as a child to the OMElement datamember that
- //we are carrying along. And return back a wrapped SOAPElement corresponding to the
+ //We will create a new OMElement and add that as a child to the OMElement datamember that
+ //we are carrying along. And return back a wrapped SOAPElement corresponding to the
//created OMElement
- org.apache.axis.om.OMElement newOMElement = new org.apache.axis.om.impl.llom.OMElementImpl(new QName(localName), omElement);
- omElement.addChild(newOMElement);
- return (SOAPElement)(new SOAPElementImpl(newOMElement));
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMFactory.newInstance().createOMElement(new QName(localName), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
}
/**
@@ -100,14 +102,14 @@
* @see javax.xml.soap.SOAPElement#addChildElement(java.lang.String, java.lang.String)
*/
public SOAPElement addChildElement(String localName, String prefix)
- throws SOAPException {
- org.apache.axis.om.OMElement newOMElement = new org.apache.axis.om.impl.llom.OMElementImpl(new QName(null,localName,prefix), omElement);
- omElement.addChild(newOMElement);
- return (SOAPElement)(new SOAPElementImpl(newOMElement));
+ throws SOAPException {
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMFactory.newInstance().createOMElement(new QName(null,localName,prefix), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
}
/**
- * Method addChileElement
+ * Method addChildElement
* @param localName
* @param prefix
* @return
@@ -116,13 +118,13 @@
*/
public SOAPElement addChildElement(String localName, String prefix,
String uri) throws SOAPException {
- org.apache.axis.om.OMElement newOMElement = new org.apache.axis.om.impl.llom.OMElementImpl(new QName(uri,localName,prefix), omElement);
- omElement.addChild(newOMElement);
- return (SOAPElement)(new SOAPElementImpl(newOMElement));
+ org.apache.axis.om.OMElement newOMElement = org.apache.axis.om.OMFactory.newInstance().createOMElement(new QName(uri,localName,prefix), omElement);
+ omElement.addChild(newOMElement);
+ return new SOAPElementImpl(newOMElement);
}
/**
- * Method addChileElement
+ * Method addChildElement
* @param element
* @return
* @throws SOAPException
@@ -135,11 +137,11 @@
//The fragment rooted in element cannot contain elements named Envelope, Header or Body
//and in the SOAP namespace. Any namespace prefixes present in the fragment should be fully
//resolved using appropriate namespace declarations within the fragment itself.
-
+
org.apache.axis.om.OMElement omElementToAdd = ((SOAPElementImpl)element).getOMElement();
omElementToAdd.setParent(omElement);
omElement.addChild(omElementToAdd);
- return (SOAPElement)(new SOAPElementImpl(omElementToAdd));
+ return new SOAPElementImpl(omElementToAdd);
}
/**
@@ -151,10 +153,10 @@
*/
public SOAPElement addTextNode(String text) throws SOAPException {
//This doesn't seem to have support directly in OM
- //But work should always be possible.
-
- //My objective would be to create an OMText node and add that to
- //the omElement delegate member that we have with us.
+ //But work around should always be possible.
+
+ //My objective would be to create an OMText node and add that to
+ //the omElement delegate member that we have with us.
omElement.setValue(text);
return this;
}
@@ -242,9 +244,9 @@
* @see javax.xml.soap.SOAPElement#getElementName()
*/
public Name getElementName() {
- //TODO: Ashu! Look into PrefixeQName implementation, and undesired extra <code>prefix</code> field
+ //TODO: Ashu! Look into PrefixeQName implementation, an undesired extra <code>prefix</code> field
//is present inside it, which might create some problems up the execution flow.
- return (Name)(new PrefixedQName(((org.apache.axis.om.impl.llom.OMElementImpl)omElement).getQName()));
+ return (Name)(new PrefixedQName(omElement.getQName()));
}
/**
@@ -264,7 +266,7 @@
* @see javax.xml.soap.SOAPElement#removeNamespaceDeclaration(java.lang.String)
*/
public boolean removeNamespaceDeclaration(String prefix) {
-
+
//Couldn't figure out corresponding functionality in OM
return false;
}
@@ -277,7 +279,7 @@
public Iterator getChildElements() {
//Actually all the children are being treated as OMNodes and are being
//wrapped accordingly to a single type and being returned
- //Ideally speaking, node type should be observed and wrapped into
+ //Ideally speaking, node type should be observed and wrapped into
//corresponding type.
Iterator childIter = omElement.getChildren();
ArrayList arrayList = new ArrayList();
@@ -317,7 +319,7 @@
* @see javax.xml.soap.SOAPElement#setEncodingStyle(java.lang.String)
*/
public void setEncodingStyle(String encodingStyle) throws SOAPException {
-
+
//Donno how to tackle this right now.
//Couldn't figure out corresponding functionality in OM
@@ -332,18 +334,19 @@
return null;
}
- /*&
+ /**
* method removeContents
* @see javax.xml.soap.SOAPElement#removeContents()
*/
public void removeContents() {
+ //We will get all the children and iteratively call the detach() on all of 'em.
+ Iterator childIter = omElement.getChildren();
- //Couldn't figure out corresponding functionality in OM
- //Actually there is a detach() method in OMElementImpl, but
- //that discards the current information item also. Here we only have to
- //remove contents and return back a void. Will have to consult
- //Venkat in making a work around for this.
-
+ while(childIter.hasNext()) {
+ Object o = childIter.next();
+ if(o instanceof org.apache.axis.om.OMNode)
+ ((org.apache.axis.om.OMNode)o).detach();
+ }
}
/**
@@ -356,16 +359,30 @@
// getAllDeclaredNamespaces() of the OMElementImpl as of now.
// But I doubt if that is going to cover the namespaces that are
// in the scope of the document at the higher levels of hierarchy
-
+
+ //I'll recursively return all the declared namespaces till this node, including its parents etc.
Iterator namespacesIter = omElement.getAllDeclaredNamespaces();
- ArrayList returnList = new ArrayList();
+ ArrayList returnList = new ArrayList();
while(namespacesIter.hasNext()) {
Object o = namespacesIter.next();
if (o instanceof org.apache.axis.om.OMNamespace) {
javax.xml.soap.Node soapNode = new NodeImpl((org.apache.axis.om.OMNamespace)o);
returnList.add(soapNode);
- }
- }
+ }
+ }//taken care of adding namespaces of this node.
+ //now we have to take care of adding the namespaces that are in the scope till the level of
+ //this nodes' parent.
+ org.apache.axis.om.OMElement parent = omElement.getParent();
+ if (parent!=null) {
+ Iterator parentScopeNamespacesIter = parent.getAllDeclaredNamespaces();
+ while(parentScopeNamespacesIter.hasNext()) {
+ Object o = parentScopeNamespacesIter.next();
+ if (o instanceof org.apache.axis.om.OMNamespace) {
+ javax.xml.soap.Node soapNode = new NodeImpl((org.apache.axis.om.OMNamespace)o);
+ returnList.add(soapNode);
+ }
+ }
+ }
return returnList.iterator();
}
@@ -411,7 +428,7 @@
*/
public void removeAttributeNS(String arg0, String arg1) throws DOMException {
-// Couldn't figure out corresponding functionality in OM
+ //Couldn't figure out corresponding functionality in OM
//but looking into OMAttribute code might help you with some work around.
}
@@ -428,7 +445,7 @@
* @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
*/
public boolean hasAttributeNS(String arg0, String arg1) {
-
+
return false;
}
@@ -436,7 +453,7 @@
* @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
*/
public Attr getAttributeNode(String arg0) {
-
+
return null;
}
@@ -444,7 +461,7 @@
* @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
*/
public Attr removeAttributeNode(Attr arg0) throws DOMException {
-
+
return null;
}
@@ -452,7 +469,7 @@
* @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
*/
public Attr setAttributeNode(Attr arg0) throws DOMException {
-
+
return null;
}
@@ -460,7 +477,7 @@
* @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
*/
public Attr setAttributeNodeNS(Attr arg0) throws DOMException {
-
+
return null;
}
@@ -468,7 +485,7 @@
* @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
*/
public NodeList getElementsByTagName(String arg0) {
-
+
return null;
}
@@ -476,7 +493,7 @@
* @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
*/
public String getAttributeNS(String arg0, String arg1) {
-
+
return null;
}
@@ -501,8 +518,8 @@
* @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
*/
public NodeList getElementsByTagNameNS(String arg0, String arg1) {
-
+
return null;
- }
+ }
}
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPEnvelopeImpl.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPEnvelopeImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPEnvelopeImpl.java Tue Apr 12 23:43:02 2005
@@ -11,8 +11,6 @@
import javax.xml.soap.SOAPHeader;
import org.apache.axis.om.OMFactory;
-import org.apache.axis.saaj.SOAPBodyImpl;
-import org.apache.axis.saaj.SOAPHeaderImpl;
/**
@@ -37,6 +35,10 @@
omSOAPEnvelope = fac.getDefaultEnvelope();
}
+ public SOAPEnvelopeImpl(org.apache.axis.om.SOAPEnvelope omEnvelope){
+ this.omSOAPEnvelope = omEnvelope;
+ }
+
/**
* method getOMEnvelope
* @return
@@ -94,12 +96,12 @@
org.apache.axis.om.SOAPHeader omSOAPHeader;
try
{
- omSOAPHeader = (org.apache.axis.om.impl.llom.SOAPHeaderImpl) omSOAPEnvelope.getHeader();
+ omSOAPHeader = (org.apache.axis.om.SOAPHeader) omSOAPEnvelope.getHeader();
}catch (Exception e)
{
throw new SOAPException(e);
}
- return (SOAPHeader) new SOAPHeaderImpl(omSOAPHeader);
+ return new SOAPHeaderImpl(omSOAPHeader);
}
/**
@@ -119,7 +121,7 @@
{
throw new SOAPException(e);
}
- return (SOAPBody)(new SOAPBodyImpl(omSOAPBody));
+ return (new SOAPBodyImpl(omSOAPBody));
}
/**
@@ -136,9 +138,10 @@
try {
org.apache.axis.om.SOAPHeader header = omSOAPEnvelope.getHeader();
if (header == null) {
- header = new org.apache.axis.om.impl.llom.SOAPHeaderImpl(omSOAPEnvelope);
+ OMFactory omFactory = OMFactory.newInstance();
+ header = omFactory.createSOAPHeader(omSOAPEnvelope);
omSOAPEnvelope.addChild(header);
- return (SOAPHeader)(new SOAPHeaderImpl(header));
+ return (new SOAPHeaderImpl(header));
} else {
throw new SOAPException("Header already present, can't set body again without deleting the existing header");
}
@@ -162,9 +165,10 @@
try {
org.apache.axis.om.SOAPBody body = omSOAPEnvelope.getBody();
if (body == null) {
- body = new org.apache.axis.om.impl.llom.SOAPBodyImpl(omSOAPEnvelope);
+ OMFactory omFactory = OMFactory.newInstance();
+ body = omFactory.createSOAPBody(omSOAPEnvelope);
omSOAPEnvelope.addChild(body);
- return (SOAPBody)(new SOAPBodyImpl(body));
+ return (new SOAPBodyImpl(body));
} else {
throw new SOAPException("Body already present, can't set body again without deleting the existing body");
}
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFaultImpl.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFaultImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPFaultImpl.java Tue Apr 12 23:43:02 2005
@@ -118,7 +118,7 @@
DetailImpl detail = new DetailImpl(detailName, fault);
OMNode entry = fault.getDetailInformation();
detail.addDetailEntry(entry);
- return (Detail)detail;
+ return detail;
}
/**
@@ -133,7 +133,7 @@
//May need to change later
QName detailName = new QName("detail");
DetailImpl detail = new DetailImpl(detailName, fault);
- return (Detail)detail;
+ return detail;
}
/**
Modified: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPHeaderImpl.java?view=diff&r1=161158&r2=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPHeaderImpl.java (original)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPHeaderImpl.java Tue Apr 12 23:43:02 2005
@@ -12,8 +12,8 @@
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
+import org.apache.axis.om.OMFactory;
import org.apache.axis.om.OMNamespace;
-import org.apache.axis.om.impl.llom.OMNamespaceImpl;
/**
* Class SOAPHeaderImpl
@@ -48,9 +48,10 @@
// Create an OMHeaderBlock out of name and add it a SOAPHeaderElement
//to SOAPHeader
String localName = name.getLocalName();
- OMNamespace ns = new OMNamespaceImpl(name.getURI(), name.getPrefix());
+ OMFactory omFactory = OMFactory.newInstance();
+ OMNamespace ns = omFactory.createOMNamespace(name.getURI(), name.getPrefix());
org.apache.axis.om.SOAPHeaderBlock headerBlock = omHeader.addHeaderBlock(localName, ns);
- return (SOAPHeaderElement)(new SOAPHeaderElementImpl(headerBlock));
+ return (new SOAPHeaderElementImpl(headerBlock));
}
/**
@@ -69,7 +70,7 @@
Object o = headerElementsIter.next();
if(o instanceof org.apache.axis.om.SOAPHeaderBlock){
org.apache.axis.om.SOAPHeaderBlock headerBlock = (org.apache.axis.om.SOAPHeaderBlock)o;
- SOAPHeaderElement element = (SOAPHeaderElement)(new SOAPHeaderElementImpl(headerBlock));
+ SOAPHeaderElement element = (new SOAPHeaderElementImpl(headerBlock));
aList.add(element);
}
}
@@ -92,7 +93,7 @@
Object o = headerElementsIter.next();
if(o instanceof org.apache.axis.om.SOAPHeaderBlock){
org.apache.axis.om.SOAPHeaderBlock headerBlock = (org.apache.axis.om.SOAPHeaderBlock)o;
- SOAPHeaderElement element = (SOAPHeaderElement)(new SOAPHeaderElementImpl(headerBlock));
+ SOAPHeaderElement element = (new SOAPHeaderElementImpl(headerBlock));
aList.add(element);
}
}
@@ -115,7 +116,7 @@
Object o = headerElementsIter.next();
if(o instanceof org.apache.axis.om.SOAPHeaderBlock){
org.apache.axis.om.SOAPHeaderBlock headerBlock = (org.apache.axis.om.SOAPHeaderBlock)o;
- SOAPHeaderElement element = (SOAPHeaderElement)(new SOAPHeaderElementImpl(headerBlock));
+ SOAPHeaderElement element = (new SOAPHeaderElementImpl(headerBlock));
aList.add(element);
}
}
@@ -137,7 +138,7 @@
Object o = headerElementsIter.next();
if(o instanceof org.apache.axis.om.SOAPHeaderBlock){
org.apache.axis.om.SOAPHeaderBlock headerBlock = (org.apache.axis.om.SOAPHeaderBlock)o;
- SOAPHeaderElement element = (SOAPHeaderElement)(new SOAPHeaderElementImpl(headerBlock));
+ SOAPHeaderElement element = (new SOAPHeaderElementImpl(headerBlock));
aList.add(element);
}
}
@@ -159,7 +160,7 @@
Object o = headerElementsIter.next();
if(o instanceof org.apache.axis.om.SOAPHeaderBlock){
org.apache.axis.om.SOAPHeaderBlock headerBlock = (org.apache.axis.om.SOAPHeaderBlock)o;
- SOAPHeaderElement element = (SOAPHeaderElement)(new SOAPHeaderElementImpl(headerBlock));
+ SOAPHeaderElement element = (new SOAPHeaderElementImpl(headerBlock));
aList.add(element);
}
}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPMessageImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,178 @@
+/*
+ * Created on Apr 8, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPHeader;
+
+import org.apache.axis.transport.http.HTTPConstants;
+
+/**
+ * @author shaas02
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SOAPMessageImpl extends SOAPMessage {
+
+ private SOAPPartImpl mSOAPPart;
+ private java.util.Hashtable mProps = new java.util.Hashtable();
+ private MimeHeaders headers;
+
+ public SOAPMessageImpl(Object initialContents){
+ setup(initialContents, false, null, null, null);
+ }
+
+ private void setup(Object initialContents, boolean bodyInStream,
+ String contentType, String contentLocation,
+ MimeHeaders mimeHeaders){
+ if(null == mSOAPPart)
+ mSOAPPart = new SOAPPartImpl(this, initialContents, bodyInStream);
+ else
+ mSOAPPart.setMessage(this);
+
+ headers = (mimeHeaders == null) ? new MimeHeaders() : new MimeHeaders(mimeHeaders);
+ }
+
+ /**
+ * Retrieves a description of this <CODE>SOAPMessage</CODE>
+ * object's content.
+ * @return a <CODE>String</CODE> describing the content of this
+ * message or <CODE>null</CODE> if no description has been
+ * set
+ * @see #setContentDescription(java.lang.String) setContentDescription(java.lang.String)
+ */
+ public String getContentDescription() {
+ String values[] = headers.getHeader(HTTPConstants.HEADER_CONTENT_DESCRIPTION);
+ if(values != null && values.length > 0)
+ return values[0];
+ return null;
+ }
+
+ /**
+ * Sets the description of this <CODE>SOAPMessage</CODE>
+ * object's content with the given description.
+ * @param description a <CODE>String</CODE>
+ * describing the content of this message
+ * @see #getContentDescription() getContentDescription()
+ */
+ public void setContentDescription(String description) {
+ headers.setHeader(HTTPConstants.HEADER_CONTENT_DESCRIPTION, description);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getSOAPPart()
+ */
+ public SOAPPart getSOAPPart() {
+ return mSOAPPart;
+ }
+
+ public SOAPBody getSOAPBody() throws SOAPException {
+ return mSOAPPart.getEnvelope().getBody();
+ }
+
+ public SOAPHeader getSOAPHeader() throws SOAPException {
+ return mSOAPPart.getEnvelope().getHeader();
+ }
+
+ public void setProperty(String property, Object value) throws SOAPException {
+ mProps.put(property, value);
+ }
+
+ public Object getProperty(String property) throws SOAPException {
+ return mProps.get(property);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#removeAllAttachments()
+ */
+ public void removeAllAttachments() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#countAttachments()
+ */
+ public int countAttachments() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getAttachments()
+ */
+ public Iterator getAttachments() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getAttachments(javax.xml.soap.MimeHeaders)
+ */
+ public Iterator getAttachments(javax.xml.soap.MimeHeaders headers) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#addAttachmentPart(javax.xml.soap.AttachmentPart)
+ */
+ public void addAttachmentPart(AttachmentPart attachmentpart) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#createAttachmentPart()
+ */
+ public AttachmentPart createAttachmentPart() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#getMimeHeaders()
+ */
+ public javax.xml.soap.MimeHeaders getMimeHeaders() {
+
+ return headers;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#saveChanges()
+ */
+ public void saveChanges() throws SOAPException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#saveRequired()
+ */
+ public boolean saveRequired() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPMessage#writeTo(java.io.OutputStream)
+ */
+ public void writeTo(OutputStream out) throws SOAPException, IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/SOAPPartImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,474 @@
+/*
+ * Created on Apr 8, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import java.util.Iterator;
+
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPPart;
+import javax.xml.transform.Source;
+
+import org.apache.axis.transport.http.HTTPConstants;
+import org.apache.axis.util.SessionUtils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Comment;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.ProcessingInstruction;
+import org.w3c.dom.Text;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class SOAPPartImpl extends SOAPPart {
+
+ private SOAPMessageImpl msgObject;
+ private MimeHeaders mimeHeaders = new MimeHeaders();
+ private Object envelope;
+ /**
+ * default message encoding charset
+ */
+ private String currentEncoding = "UTF-8";
+
+ public SOAPPartImpl(SOAPMessageImpl parent, Object initialContents, boolean isBodyStream){
+
+ setMimeHeader(HTTPConstants.HEADER_CONTENT_ID , SessionUtils.generateSessionId());
+ setMimeHeader(HTTPConstants.HEADER_CONTENT_TYPE , "text/xml");
+
+ msgObject = parent;
+ if(initialContents instanceof SOAPEnvelope){
+ ((SOAPEnvelopeImpl)initialContents).setOwnerDocument(this);
+ envelope = initialContents;
+ }
+ }
+
+ public SOAPMessageImpl getMessage(){
+ return msgObject;
+ }
+
+ /**
+ * Set the Message for this Part.
+ * Do not call this Directly. Called by Message.
+ *
+ * @param msg the <code>Message</code> for this part
+ */
+ public void setMessage (SOAPMessageImpl msg) {
+ this.msgObject= msg;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPPart#getEnvelope()
+ */
+ public SOAPEnvelope getEnvelope() throws SOAPException {
+ //if(envelope != null)
+ return (SOAPEnvelope)envelope;
+
+ }
+
+ /**
+ * Removes all MIME headers that match the given name.
+ * @param header a <CODE>String</CODE> giving
+ * the name of the MIME header(s) to be removed
+ */
+ public void removeMimeHeader(String header) {
+ mimeHeaders.removeHeader(header);
+ }
+
+ /**
+ * Removes all the <CODE>MimeHeader</CODE> objects for this
+ * <CODE>SOAPEnvelope</CODE> object.
+ */
+ public void removeAllMimeHeaders() {
+ mimeHeaders.removeAllHeaders();
+ }
+
+ /**
+ * Gets all the values of the <CODE>MimeHeader</CODE> object
+ * in this <CODE>SOAPPart</CODE> object that is identified by
+ * the given <CODE>String</CODE>.
+ * @param name the name of the header; example:
+ * "Content-Type"
+ * @return a <CODE>String</CODE> array giving all the values for
+ * the specified header
+ * @see #setMimeHeader(java.lang.String, java.lang.String) setMimeHeader(java.lang.String, java.lang.String)
+ */
+ public String[] getMimeHeader(String name) {
+ return mimeHeaders.getHeader(name);
+ }
+
+ /**
+ * Changes the first header entry that matches the given
+ * header name so that its value is the given value, adding a
+ * new header with the given name and value if no existing
+ * header is a match. If there is a match, this method clears
+ * all existing values for the first header that matches and
+ * sets the given value instead. If more than one header has
+ * the given name, this method removes all of the matching
+ * headers after the first one.
+ *
+ * <P>Note that RFC822 headers can contain only US-ASCII
+ * characters.</P>
+ * @param name a <CODE>String</CODE> giving the
+ * header name for which to search
+ * @param value a <CODE>String</CODE> giving the
+ * value to be set. This value will be substituted for the
+ * current value(s) of the first header that is a match if
+ * there is one. If there is no match, this value will be
+ * the value for a new <CODE>MimeHeader</CODE> object.
+ * @ throws java.lang.IllegalArgumentException if
+ * there was a problem with the specified mime header name
+ * or value
+ * @see #getMimeHeader(java.lang.String) getMimeHeader(java.lang.String)
+ */
+ public void setMimeHeader(String name, String value) {
+ mimeHeaders.setHeader(name,value);
+ }
+
+ /**
+ * Add the specified MIME header, as per JAXM.
+ *
+ * @param header the header to add
+ * @param value the value of that header
+ */
+ public void addMimeHeader (String header, String value) {
+ mimeHeaders.addHeader(header, value);
+ }
+
+ /**
+ * Retrieves all the headers for this <CODE>SOAPPart</CODE>
+ * object as an iterator over the <CODE>MimeHeader</CODE>
+ * objects.
+ * @return an <CODE>Iterator</CODE> object with all of the Mime
+ * headers for this <CODE>SOAPPart</CODE> object
+ */
+ public Iterator getAllMimeHeaders() {
+ return mimeHeaders.getAllHeaders();
+ }
+
+ /**
+ * Get all headers that match.
+ *
+ * @param match an array of <code>String</code>s giving mime header names
+ * @return an <code>Iterator</code> over all values matching these headers
+ */
+ public java.util.Iterator getMatchingMimeHeaders( final String[] match){
+ return mimeHeaders.getMatchingHeaders(match);
+ }
+
+ /**
+ * Get all headers that do not match.
+ *
+ * @param match an array of <code>String</code>s giving mime header names
+ * @return an <code>Iterator</code> over all values not matching these
+ * headers
+ */
+ public java.util.Iterator getNonMatchingMimeHeaders( final String[] match){
+ return mimeHeaders.getNonMatchingHeaders(match);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPPart#setContent(javax.xml.transform.Source)
+ */
+ public void setContent(Source source) throws SOAPException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.soap.SOAPPart#getContent()
+ */
+ public Source getContent() throws SOAPException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Implementation of org.w3c.Document
+ * Most of methods will be implemented using the delgate
+ * instance of SOAPDocumentImpl
+ * This is for two reasons:
+ * - possible change of message classes, by extenstion of xerces implementation
+ * - we cannot extends SOAPPart (multiple inheritance),
+ * since it is defined as Abstract class
+ * ***********************************************************
+ */
+
+ private Document document = new SOAPDocumentImpl(this);
+ /**
+ * @since SAAJ 1.2
+ */
+ public Document getSOAPDocument(){
+ if(document == null){
+ document = new SOAPDocumentImpl(this);
+ }
+ return document;
+ }
+
+ /**
+ * @return
+ */
+ public DocumentType getDoctype(){
+ return document.getDoctype();
+ }
+
+ /**
+ * @return
+ */
+ public DOMImplementation getImplementation(){
+ return document.getImplementation();
+ }
+
+ /**
+ * SOAPEnvelope is the Document Elements of this XML docuement
+ */
+ protected Document mDocument;
+
+ public Element getDocumentElement()
+ {
+ try{
+ return getEnvelope();
+ }catch(SOAPException se){
+ return null;
+ }
+ }
+
+ /**
+ *
+ * @param tagName
+ * @return
+ * @throws DOMException
+ */
+ public Element createElement(String tagName) throws DOMException {
+ return document.createElement(tagName);
+ }
+
+ public DocumentFragment createDocumentFragment() {
+ return document.createDocumentFragment();
+ }
+
+ public Text createTextNode(String data) {
+ return document.createTextNode(data);
+ }
+
+ public Comment createComment(String data){
+ return document.createComment(data);
+ }
+
+ public CDATASection createCDATASection(String data) throws DOMException {
+ return document.createCDATASection(data);
+ }
+
+ public ProcessingInstruction createProcessingInstruction(String target, String data)
+ throws DOMException {
+ return document.createProcessingInstruction(target,data);
+ }
+
+ public Attr createAttribute(String name)throws DOMException {
+ return document.createAttribute(name);
+ }
+
+ public EntityReference createEntityReference(String name) throws DOMException {
+ return document.createEntityReference(name);
+ }
+
+ public NodeList getElementsByTagName(String tagname) {
+ return document.getElementsByTagName(tagname);
+ }
+
+ public Node importNode(Node importedNode, boolean deep)
+ throws DOMException {
+ return document.importNode(importedNode, deep);
+ }
+
+ public Element createElementNS(String namespaceURI, String qualifiedName)
+ throws DOMException {
+ return document.createElementNS(namespaceURI, qualifiedName);
+ }
+
+ public Attr createAttributeNS(String namespaceURI, String qualifiedName)
+ throws DOMException {
+ return document.createAttributeNS(namespaceURI, qualifiedName);
+ }
+
+ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
+ return document.getElementsByTagNameNS(namespaceURI,localName);
+ }
+
+ public Element getElementById(String elementId){
+ return document.getElementById(elementId);
+ }
+
+ /////////////////////////////////////////////////////////////
+
+ public String getEncoding()
+ {
+ return currentEncoding;
+ }
+
+ public void setEncoding(String s)
+ {
+ currentEncoding = s;
+ }
+
+ public boolean getStandalone()
+ {
+ throw new UnsupportedOperationException("Not yet implemented.71");
+ }
+
+
+ public void setStandalone(boolean flag)
+ {
+ throw new UnsupportedOperationException("Not yet implemented.72");
+ }
+
+ public boolean getStrictErrorChecking()
+ {
+ throw new UnsupportedOperationException("Not yet implemented.73");
+ }
+
+
+ public void setStrictErrorChecking(boolean flag)
+ {
+ throw new UnsupportedOperationException("Not yet implemented. 74");
+ }
+
+
+ public String getVersion()
+ {
+ throw new UnsupportedOperationException("Not yet implemented. 75");
+ }
+
+
+ public void setVersion(String s)
+ {
+ throw new UnsupportedOperationException("Not yet implemented.76");
+ }
+
+
+ public Node adoptNode(Node node)
+ throws DOMException
+ {
+ throw new UnsupportedOperationException("Not yet implemented.77");
+ }
+
+ /**
+ * Node Implementation
+ */
+
+ public String getNodeName(){
+ return document.getNodeName();
+ }
+
+ public String getNodeValue() throws DOMException {
+ return document.getNodeValue();
+ }
+
+ public void setNodeValue(String nodeValue) throws DOMException{
+ document.setNodeValue(nodeValue);
+ }
+
+ public short getNodeType() {
+ return document.getNodeType();
+ }
+
+ public Node getParentNode(){
+ return document.getParentNode();
+ }
+
+ public NodeList getChildNodes() {
+ return document.getChildNodes();
+ }
+
+ public Node getFirstChild() {
+ return document.getFirstChild();
+ }
+
+ public Node getLastChild(){
+ return document.getLastChild();
+ }
+
+ public Node getPreviousSibling(){
+ return document.getPreviousSibling();
+ }
+
+ public Node getNextSibling(){
+ return document.getNextSibling();
+ }
+
+ public NamedNodeMap getAttributes(){
+ return document.getAttributes();
+ }
+
+ public Document getOwnerDocument(){
+ return document.getOwnerDocument();
+ }
+
+ public Node insertBefore(Node newChild, Node refChild) throws DOMException {
+ return document.insertBefore(newChild, refChild);
+ }
+
+ public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
+ return document.replaceChild(newChild, oldChild);
+ }
+
+ public Node removeChild(Node oldChild) throws DOMException {
+ return document.removeChild(oldChild);
+ }
+
+ public Node appendChild(Node newChild) throws DOMException {
+ return document.appendChild(newChild);
+ }
+
+ public boolean hasChildNodes(){
+ return document.hasChildNodes();
+ }
+ public Node cloneNode(boolean deep) {
+ return document.cloneNode(deep);
+ }
+
+ public void normalize(){
+ document.normalize();
+ }
+
+ public boolean isSupported(String feature, String version){
+ return document.isSupported(feature, version);
+ }
+
+ public String getNamespaceURI() {
+ return document.getNamespaceURI();
+ }
+
+ public String getPrefix() {
+ return document.getPrefix();
+ }
+
+ public void setPrefix(String prefix) throws DOMException {
+ document.setPrefix(prefix);
+ }
+ public String getLocalName() {
+ return document.getLocalName();
+ }
+
+ public boolean hasAttributes(){
+ return document.hasAttributes();
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/TextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/TextImpl.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/TextImpl.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/saaj/TextImpl.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,168 @@
+/*
+ * Created on Apr 11, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.saaj;
+
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.Text;
+import javax.xml.soap.SOAPException;
+
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMText;
+import org.w3c.dom.DOMException;
+
+/**
+ * @author Ashutosh Shahi ashutosh.shahi@gmail.com
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class TextImpl extends NodeImpl implements Text {
+
+ private OMText omText;
+
+ public TextImpl(String s){
+ //super();
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(s);
+ }
+
+ public TextImpl(SOAPElementImpl parent, String s) throws SOAPException{
+ //super();
+ //super.setParentElement(parent);
+ OMElement par = parent.getOMElement();
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(par, s);
+ omNode = omText;
+ }
+
+ public TextImpl(org.w3c.dom.CharacterData data){
+ if ( data == null ){
+ throw new IllegalArgumentException( "Text value may not be null." );
+ }
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(data.getData());
+ }
+
+ /*Overridden Method*/
+ public SOAPElement getParentElement() {
+ OMElement parent = omText.getParent();
+ return new SOAPElementImpl(parent);
+ }
+
+ /*Overridden Method*/
+ public void setParentElement(SOAPElement parent) throws SOAPException {
+ OMElement omParent = ((SOAPElementImpl)parent).getOMElement();
+ omText.setParent(omParent);
+ }
+
+ /*Overridden Method*/
+ public String getValue() {
+ return omText.getValue();
+ }
+
+ public boolean isComment() {
+
+ String temp = omText.getValue();
+ if(temp.startsWith("<!--") && temp.endsWith("-->"))
+ return true;
+ return false;
+ }
+
+ /**
+ * Implementation of DOM TEXT Interface
+ * *************************************************************
+ */
+
+
+ public org.w3c.dom.Text splitText(int offset) throws DOMException {
+
+ String temp = omText.getValue();
+ int length = temp.length();
+ String tailData = temp.substring(offset);
+ temp = temp.substring(0, offset);
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(temp);
+ TextImpl tailText = new TextImpl(tailData);
+ org.w3c.dom.Node myParent = getParentNode();
+ if(myParent != null){
+ org.w3c.dom.NodeList brothers = myParent.getChildNodes();
+ for(int i = 0;i < brothers.getLength(); i++){
+ if(brothers.item(i).equals(this)){
+ myParent.insertBefore(tailText, this);
+ return tailText;
+ }
+ }
+ }
+ return tailText;
+ }
+
+
+ public int getLength() {
+
+ return omText.getValue().length();
+ }
+
+
+ public void deleteData(int offset, int count) throws DOMException {
+
+ String temp = omText.getValue();
+ StringBuffer subString = new StringBuffer(temp.substring(0,offset));
+ if(temp.length() - offset >= count - offset)
+ subString = subString.append(temp.substring(offset+count));
+ temp = subString.toString();
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(temp);
+
+ }
+
+
+ public String getData() throws DOMException {
+
+ return omText.getValue();
+ }
+
+
+ public String substringData(int offset, int count) throws DOMException {
+
+ String temp = omText.getValue();
+ if(temp.length() - offset >= count - offset)
+ return temp.substring(offset, count);
+ else
+ return temp.substring(offset);
+ }
+
+
+ public void replaceData(int offset, int count, String arg)
+ throws DOMException {
+
+ deleteData(offset, count);
+ StringBuffer temp = new StringBuffer(omText.getValue());
+ temp.append(arg);
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(temp.toString());
+ }
+
+
+ public void insertData(int offset, String arg) throws DOMException {
+
+ if(offset < 0 || offset > omText.getValue().length())
+ throw new DOMException(DOMException.INDEX_SIZE_ERR, "");
+ StringBuffer temp = new StringBuffer(omText.getValue().substring(0, offset));
+ temp = temp.append(arg);
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(temp.toString());
+ }
+
+
+ public void appendData(String arg) throws DOMException {
+
+ StringBuffer temp = new StringBuffer(omText.getValue());
+ temp = temp.append(arg);
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(temp.toString());
+
+ }
+
+
+ public void setData(String arg) throws DOMException {
+
+ omText = org.apache.axis.om.OMFactory.newInstance().createText(arg);
+ }
+
+}
Added: webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/IOUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/IOUtils.java?view=auto&rev=161159
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/IOUtils.java (added)
+++ webservices/axis/trunk/archive/java/scratch/ashu_jaya_venkat/saaj/src/java/org/apache/axis/util/IOUtils.java Tue Apr 12 23:43:02 2005
@@ -0,0 +1,55 @@
+/*
+ * Created on Apr 7, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.axis.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Utility class containing IO helper methods
+ */
+public class IOUtils
+{
+ private IOUtils() {
+ }
+
+ /**
+ * Read into a byte array; tries to ensure that the the
+ * full buffer is read.
+ *
+ * Helper method, just calls <tt>readFully(in, b, 0, b.length)</tt>
+ * @see #readFully(java.io.InputStream, byte[], int, int)
+ */
+ public static int readFully(InputStream in, byte[] b)
+ throws IOException
+ {
+ return readFully(in, b, 0, b.length);
+ }
+
+ /**
+ * Same as the normal <tt>in.read(b, off, len)</tt>, but tries to ensure that
+ * the entire len number of bytes is read.
+ * <p>
+ * @returns the number of bytes read, or -1 if the end of file is
+ * reached before any bytes are read
+ */
+ public static int readFully(InputStream in, byte[] b, int off, int len)
+ throws IOException
+ {
+ int total = 0;
+ for (;;) {
+ int got = in.read(b, off + total, len - total);
+ if (got < 0) {
+ return (total == 0) ? -1 : total;
+ } else {
+ total += got;
+ if (total == len)
+ return total;
+ }
+ }
+ }
+}