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 da...@apache.org on 2007/01/31 21:35:35 UTC
svn commit: r501978 [17/24] - in /webservices/axis2/branches/java/maven2: ./
etc/ modules/adb-codegen/ modules/adb-codegen/src/org/apache/axis2/schema/
modules/adb-codegen/src/org/apache/axis2/schema/template/
modules/adb-codegen/src/org/apache/axis2/s...
Modified: webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/SAAJFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/SAAJFactory.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/SAAJFactory.java (original)
+++ webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/SAAJFactory.java Wed Jan 31 12:35:21 2007
@@ -22,10 +22,10 @@
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
+import javax.xml.ws.WebServiceException;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.message.MessageException;
/**
* Provides convenience methods to construct a SOAP 1.1 or SOAP 1.2 SAAJ MessageFactory or SOAPFactory.
@@ -47,14 +47,14 @@
* @param namespace
* @return
*/
- public static SOAPFactory createSOAPFactory(String namespace) throws MessageException, SOAPException {
+ public static SOAPFactory createSOAPFactory(String namespace) throws WebServiceException, SOAPException {
Method m = getSOAPFactoryNewInstanceProtocolMethod();
SOAPFactory sf = null;
if (m == null) {
if (namespace.equals(SOAP11_ENV_NS)) {
sf = SOAPFactory.newInstance();
} else {
- throw ExceptionFactory.makeMessageException(Messages.getMessage("SOAP12WithSAAJ12Err"));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("SOAP12WithSAAJ12Err"));
}
} else {
String protocol = DYNAMIC_PROTOCOL;
@@ -66,7 +66,7 @@
try {
sf = (SOAPFactory) m.invoke(null, new Object[] {protocol});
} catch (Exception e) {
- throw ExceptionFactory.makeMessageException(e);
+ throw ExceptionFactory.makeWebServiceException(e);
}
}
return sf;
@@ -77,14 +77,14 @@
* @param namespace
* @return
*/
- public static MessageFactory createMessageFactory(String namespace) throws MessageException, SOAPException {
+ public static MessageFactory createMessageFactory(String namespace) throws WebServiceException, SOAPException {
Method m = getMessageFactoryNewInstanceProtocolMethod();
MessageFactory mf = null;
if (m == null) {
if (namespace.equals(SOAP11_ENV_NS)) {
mf = MessageFactory.newInstance();
} else {
- throw ExceptionFactory.makeMessageException(Messages.getMessage("SOAP12WithSAAJ12Err"));
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("SOAP12WithSAAJ12Err"));
}
} else {
String protocol = DYNAMIC_PROTOCOL;
@@ -96,7 +96,7 @@
try {
mf = (MessageFactory) m.invoke(null, new Object[] {protocol});
} catch (Exception e) {
- throw ExceptionFactory.makeMessageException(e);
+ throw ExceptionFactory.makeWebServiceException(e);
}
}
return mf;
Modified: webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java (original)
+++ webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java Wed Jan 31 12:35:21 2007
@@ -17,9 +17,12 @@
package org.apache.axis2.jaxws.util;
+import java.io.FileNotFoundException;
import java.io.InputStream;
+import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -42,7 +45,8 @@
private Definition wsdlDefinition = null;
private URL wsdlURL;
- public WSDL4JWrapper(URL wsdlURL)throws WSDLException{
+ public WSDL4JWrapper(URL wsdlURL)throws FileNotFoundException, UnknownHostException,
+ ConnectException, WSDLException{
super();
this.wsdlURL = wsdlURL;
WSDLFactory factory = WSDLFactory.newInstance();
@@ -54,10 +58,18 @@
InputStream is = urlCon.getInputStream();
is.close();
String explicitWsdl = urlCon.getURL().toString();
-
wsdlDefinition = reader.readWSDL(explicitWsdl);
-
- } catch (Exception ex) {
+ }
+ catch(FileNotFoundException ex) {
+ throw ex;
+ }
+ catch(UnknownHostException ex) {
+ throw ex;
+ }
+ catch(ConnectException ex) {
+ throw ex;
+ }
+ catch (Exception ex) {
throw new WSDLException("WSDL4JWrapper : ", ex.getMessage());
}
}
Modified: webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java (original)
+++ webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/util/XMLRootElementUtil.java Wed Jan 31 12:35:21 2007
@@ -20,6 +20,8 @@
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
@@ -28,6 +30,8 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.namespace.QName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This utility contains code to determine if an Object is
@@ -73,6 +77,8 @@
*
*/
public class XMLRootElementUtil {
+
+ private static final Log log = LogFactory.getLog(XMLRootElementUtil.class);
/**
* Constructor is intentionally private. This class only provides static utility methods
@@ -160,7 +166,7 @@
return ((JAXBElement) obj).getName();
}
- Class clazz = obj.getClass();
+ Class clazz = (obj instanceof java.lang.Class) ? (Class) obj : obj.getClass();
// If the clazz is a primitive, then it does not have a corresponding root element.
if (clazz.isPrimitive() ||
@@ -200,16 +206,41 @@
*/
public static Map<String, PropertyDescriptor> createPropertyDescriptorMap(Class jaxbClass) throws NoSuchFieldException, IntrospectionException {
- // TODO This is a very performance intensive search we should cache the calculated map keyed by the jaxbClass
+ if (log.isDebugEnabled()) {
+ log.debug("Get the PropertyDescriptor[] for " + jaxbClass);
+ }
+ // TODO This is a very performance intensive search we should cache the calculated map keyed by the jaxbClass
PropertyDescriptor[] pds = Introspector.getBeanInfo(jaxbClass).getPropertyDescriptors();
- // Make this a weak map in case we want to cache the resolts
+ // Make this a weak map in case we want to cache the results
Map<String, PropertyDescriptor> map = new WeakHashMap<String, PropertyDescriptor>();
// Unfortunately the element names are stored on the fields.
- // Therefore we need to to match up the field and property descriptor
- Field[] fields = jaxbClass.getDeclaredFields();
+ // Get all of the fields in the class and super classes
+ List<Field> fields = new ArrayList<Field>();
+ Class cls = jaxbClass;
+ while(cls != null) {
+ Field[] fieldArray = cls.getDeclaredFields();
+ for (Field field:fieldArray) {
+ fields.add(field);
+ }
+ cls = cls.getSuperclass();
+ }
+
+ // Now match up the fields with the property descriptors...Sigh why didn't JAXB put the @XMLElement annotations on the
+ // property methods!
for(PropertyDescriptor pd:pds){
+
+ // Skip over the class property..it is never represented as an xml element
+ if (pd.getName().equals("class")) {
+ continue;
+ }
+
+ // For the current property, find a matching field...so that we can get the xml name
+ boolean found = false;
+ if (log.isDebugEnabled()) {
+ log.debug(" Start: Find xmlname for property:" + pd.getName());
+ }
for(Field field:fields){
String fieldName = field.getName();
@@ -217,7 +248,16 @@
if (fieldName.equalsIgnoreCase(pd.getDisplayName()) ||
fieldName.equalsIgnoreCase(pd.getName()) ) {
// Get the xmlElement name for this field
- String xmlName =getXmlElementName(jaxbClass, field);
+ String xmlName =getXmlElementName(field.getDeclaringClass(), field);
+ found = true;
+ if (log.isDebugEnabled()) {
+ log.debug(" Found field " + field.getName() + " which has xmlname=" + xmlName);
+ }
+ if (map.get(xmlName) != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(" ALERT: property " + map.get(xmlName).getName() + " already has this same xmlName..this may cause problems.");
+ }
+ }
map.put(xmlName, pd);
break;
}
@@ -228,11 +268,37 @@
if (fieldName.equalsIgnoreCase(pd.getDisplayName()) ||
fieldName.equalsIgnoreCase(pd.getName())) {
// Get the xmlElement name for this field
- String xmlName =getXmlElementName(jaxbClass, field);
+ String xmlName =getXmlElementName(field.getDeclaringClass(), field);
+ found = true;
+ if (log.isDebugEnabled()) {
+ log.debug(" Found field " + field.getName() + " which has xmlname=" + xmlName);
+ }
+ if (map.get(xmlName) != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(" ALERT: property " + map.get(xmlName).getName() + " already has this same xmlName..this may cause problems.");
+ }
+ }
map.put(xmlName, pd);
break;
}
}
+ }
+
+ // We didn't find a field. Default the xmlname to the property name
+ if (!found) {
+ String xmlName = pd.getName();
+ if (log.isDebugEnabled()) {
+ log.debug(" A matching field was not found. Defaulting xmlname to " + xmlName);
+ }
+ if (map.get(xmlName) != null) {
+ if (log.isDebugEnabled()) {
+ log.debug(" ALERT: property " + map.get(xmlName).getName() + " already has this same xmlName..this may cause problems.");
+ }
+ }
+ map.put(xmlName, pd);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(" End: Find xmlname for property:" + pd.getName());
}
}
return map;
Modified: webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/wsdl/impl/SchemaReaderImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/wsdl/impl/SchemaReaderImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/wsdl/impl/SchemaReaderImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/metadata/src/org/apache/axis2/jaxws/wsdl/impl/SchemaReaderImpl.java Wed Jan 31 12:35:21 2007
@@ -51,7 +51,13 @@
//Read Schema Definition in wsdl;
Types types = wsdlDefinition.getTypes();
-
+ if(types == null){
+ if(log.isDebugEnabled()){
+ log.debug("WARNING: Could not find any Scheam/Types from WSDL");
+ log.debug("no packages will derived from WSDL schema");
+ }
+ return set;
+ }
List extensibilityElements = types.getExtensibilityElements();
//Read the schema defined in the wsdl
Modified: webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/PartialWSDLTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/PartialWSDLTests.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/PartialWSDLTests.java (original)
+++ webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/PartialWSDLTests.java Wed Jan 31 12:35:21 2007
@@ -24,12 +24,19 @@
import javax.jws.WebService;
import javax.wsdl.Definition;
+import javax.xml.ws.WebServiceException;
import junit.framework.TestCase;
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
import org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite;
import org.apache.axis2.jaxws.description.builder.WebServiceAnnot;
+import org.apache.axis2.jaxws.description.builder.MDQConstants;
+import org.apache.axis2.jaxws.description.builder.WsdlComposite;
+import org.apache.axis2.jaxws.description.builder.WsdlGenerator;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+
/**
*
@@ -78,6 +85,7 @@
dbc.setClassName(AddNumbersImplPartial1.class.getName());
dbc.setWsdlDefinition(wsdlDefn);
dbc.setwsdlURL(wsdlURL);
+ dbc.setCustomWsdlGenerator(new WSDLGeneratorImpl(wsdlDefn));
HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
dbcMap.put(AddNumbersImplPartial1.class.getName(), dbc);
@@ -86,6 +94,7 @@
assertEquals(1, serviceDescList.size());
ServiceDescription sd = serviceDescList.get(0);
assertNotNull(sd);
+
EndpointDescription[] edArray = sd.getEndpointDescriptions();
assertNotNull(edArray);
@@ -93,6 +102,13 @@
EndpointDescription ed = edArray[0];
assertNotNull(ed);
+ // Test for presence of generated WSDL
+ AxisService as = ed.getAxisService();
+ assertNotNull(as);
+ Parameter compositeParam = as.getParameter(MDQConstants.WSDL_COMPOSITE);
+ assertNotNull(compositeParam);
+ assertNotNull(compositeParam.getValue());
+
EndpointInterfaceDescription eid = ed.getEndpointInterfaceDescription();
assertNotNull(eid);
@@ -143,6 +159,7 @@
dbc.setClassName(AddNumbersImplPartial1.class.getName());
dbc.setWsdlDefinition(wsdlDefn);
dbc.setwsdlURL(wsdlURL);
+ dbc.setCustomWsdlGenerator(new WSDLGeneratorImpl(wsdlDefn));
HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String, DescriptionBuilderComposite>();
dbcMap.put(AddNumbersImplPartial1.class.getName(), dbc);
@@ -158,6 +175,13 @@
EndpointDescription ed = edArray[0];
assertNotNull(ed);
+ // Test for presence of generated WSDL
+ AxisService as = ed.getAxisService();
+ assertNotNull(as);
+ Parameter compositeParam = as.getParameter(MDQConstants.WSDL_COMPOSITE);
+ assertNotNull(compositeParam);
+ assertNotNull(compositeParam.getValue());
+
EndpointInterfaceDescription eid = ed.getEndpointInterfaceDescription();
assertNotNull(eid);
@@ -175,3 +199,24 @@
return number1 + number2;
}
}
+
+class WSDLGeneratorImpl implements WsdlGenerator {
+
+ private Definition def;
+
+ public WSDLGeneratorImpl(Definition def) {
+ this.def = def;
+ }
+
+ public WsdlComposite generateWsdl(String implClass, String bindingType) throws WebServiceException {
+ // Need WSDL generation code
+ WsdlComposite composite = new WsdlComposite();
+ composite.setWsdlFileName(implClass);
+ HashMap<String, Definition> testMap = new HashMap<String, Definition>();
+ testMap.put(composite.getWsdlFileName(), def);
+ composite.setWsdlDefinition(testMap);
+ return composite;
+ }
+
+}
+
Modified: webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java (original)
+++ webservices/axis2/branches/java/maven2/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java Wed Jan 31 12:35:21 2007
@@ -21,6 +21,7 @@
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
+import javax.xml.ws.WebFault;
import junit.framework.TestCase;
@@ -39,7 +40,12 @@
assertEquals("org.apache.axis2.jaxws.description.Method1", requestWrapperClass);
String responseWrapperClass = opDesc.getResponseWrapperClassName();
assertEquals("org.apache.axis2.jaxws.description.Method1Response", responseWrapperClass);
-
+ FaultDescription fDesc = opDesc.getFaultDescriptions()[0];
+ String faultExceptionClass = fDesc.getExceptionClassName();
+ assertEquals("org.apache.axis2.jaxws.description.Method1Exception", faultExceptionClass);
+ String faultBeanClass = fDesc.getFaultBean();
+ assertEquals("org.apache.axis2.jaxws.description.ExceptionBean", faultBeanClass);
+
}
public void testSEISubPackageWrapper() {
@@ -49,7 +55,12 @@
assertEquals("org.apache.axis2.jaxws.description.jaxws.SubPackageMethod1", requestWrapperClass);
String responseWrapperClass = opDesc.getResponseWrapperClassName();
assertEquals("org.apache.axis2.jaxws.description.jaxws.SubPackageMethod1Response", responseWrapperClass);
-
+ FaultDescription fDesc = opDesc.getFaultDescriptions()[0];
+ String faultExceptionClass = fDesc.getExceptionClassName();
+ assertEquals("org.apache.axis2.jaxws.description.SubPackageException", faultExceptionClass);
+ String faultBeanClass = fDesc.getFaultBean();
+ assertEquals("org.apache.axis2.jaxws.description.jaxws.SubPackageExceptionBean", faultBeanClass);
+
}
/*
@@ -78,7 +89,7 @@
class SEIPackageWrapper {
@RequestWrapper()
@ResponseWrapper()
- public String method1(String string) {
+ public String method1(String string) throws Method1Exception {
return string;
}
}
@@ -91,11 +102,25 @@
}
+@WebFault()
+class Method1Exception extends Exception {
+ public ExceptionBean getFaultInfo() { return null; }
+}
+
+class ExceptionBean {
+
+}
+
+@WebFault
+class SubPackageException extends Exception {
+ // No getFaultInfo method
+}
+
@WebService()
class SEISubPackageWrapper {
@RequestWrapper()
@ResponseWrapper()
- public String subPackageMethod1(String string) {
+ public String subPackageMethod1(String string) throws SubPackageException {
return string;
}
}
Modified: webservices/axis2/branches/java/maven2/modules/rahas/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/rahas/project.xml?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/rahas/project.xml (original)
+++ webservices/axis2/branches/java/maven2/modules/rahas/project.xml Wed Jan 31 12:35:21 2007
@@ -187,7 +187,7 @@
</properties>
</dependency>
<dependency>
- <groupId>incubator-woden</groupId>
+ <groupId>org.apache.woden</groupId>
<artifactId>woden</artifactId>
<version>${woden.version}</version>
<properties>
Modified: webservices/axis2/branches/java/maven2/modules/saaj-api/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj-api/project.xml?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj-api/project.xml (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj-api/project.xml Wed Jan 31 12:35:21 2007
@@ -70,5 +70,12 @@
<module>true</module>
</properties>
</dependency>
+ <!--
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
+ -->
</dependencies>
</project>
Modified: webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/MessageFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/MessageFactory.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/MessageFactory.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/MessageFactory.java Wed Jan 31 12:35:21 2007
@@ -145,6 +145,8 @@
*
* @return a new <CODE>SOAPMessage</CODE> object
* @throws SOAPException if a SOAP error occurs
+ * java.lang.UnsupportedOperationException - if the protocol of this
+ * MessageFactory instance is DYNAMIC_SOAP_PROTOCOL
*/
public abstract SOAPMessage createMessage() throws SOAPException;
@@ -172,7 +174,8 @@
throws SOAPException {
if(!(SOAPConstants.SOAP_1_1_PROTOCOL.equals(soapVersion) ||
- SOAPConstants.SOAP_1_2_PROTOCOL.equals(soapVersion))){
+ SOAPConstants.SOAP_1_2_PROTOCOL.equals(soapVersion) ||
+ SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(soapVersion))){
throw new SOAPException("Invalid SOAP Protocol Version");
}
Modified: webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SAAJResult.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SAAJResult.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SAAJResult.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SAAJResult.java Wed Jan 31 12:35:21 2007
@@ -18,13 +18,14 @@
import javax.xml.transform.dom.DOMResult;
-import org.w3c.dom.*;
-
public class SAAJResult extends DOMResult {
public SAAJResult()
throws SOAPException {
this(MessageFactory.newInstance().createMessage());
+ org.w3c.dom.Node node = this.getNode();
+ node.removeChild(node.getFirstChild());
+ this.setNode(null);
}
public SAAJResult(String s)
@@ -42,6 +43,10 @@
public javax.xml.soap.Node getResult() {
org.w3c.dom.Node node = super.getNode();
+ //When using SAAJResult saajResult = new SAAJResult();
+ if (node == null){
+ return null;
+ }
if(node instanceof SOAPPart){
try {
return ((SOAPPart)node).getEnvelope();
@@ -51,4 +56,6 @@
}
return (javax.xml.soap.Node) node.getFirstChild();
}
+
+
}
Modified: webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPConnection.java Wed Jan 31 12:35:21 2007
@@ -15,6 +15,11 @@
*/
package javax.xml.soap;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
/**
* A point-to-point connection that a client can use for sending messages
* directly to a remote party (represented by a URL, for instance).
@@ -61,8 +66,33 @@
*/
public abstract void close() throws SOAPException;
- public SOAPMessage get(Object obj)
+ /**
+ * Gets a message from a specific endpoint and blocks until it receives,
+ * @param to - an Object that identifies where the request should be sent. Objects of type
+ * java.lang.String and java.net.URL must be supported.
+ * @return the SOAPMessage object that is the response to the get message request
+ * @throws SOAPException - if there is a SOAP error
+ */
+ public SOAPMessage get(Object to)
throws SOAPException {
- throw new UnsupportedOperationException();
+ URL url = null;
+ try
+ {
+ url = (to instanceof URL) ? (URL) to : new URL(to.toString());
+ if(url != null){
+ //InputStream in = url.openStream();
+ //TODO : setting null for mime headers
+ // close the connection??
+ SOAPMessage soapMessage = null;
+ //new SOAPMessageImpl(in,null);
+ return soapMessage;
+ }
+ return null;
+ }catch (MalformedURLException e) {
+ throw new SOAPException(e);
+ }catch (IOException e) {
+ throw new SOAPException(e);
+ }
+
}
}
Modified: webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFactory.java Wed Jan 31 12:35:21 2007
@@ -161,19 +161,14 @@
* @see <CODE>SAAJMetaFactory</CODE>
*/
public static SOAPFactory newInstance(String protocol) throws SOAPException {
- //TODO : check, how to load from SAAJMetaFactory
- //this is what was here earlier
- // s == protocol
- //return (SOAPFactory) Class.forName(s).newInstance();
- //Is returning classes from axiom correct?
- //what about DYNAMIC_SOAP_PROTOCOL?
try {
- if(SOAPConstants.DEFAULT_SOAP_PROTOCOL.equals(protocol) || SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)){
- return (SOAPFactory) Class.forName("org.apache.axis2.saaj.SOAPFactoryImpl").newInstance();
- }else if(SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
- return (SOAPFactory) Class.forName("org.apache.axis2.saaj.SOAPFactoryImpl").newInstance();
+ if(SOAPConstants.DEFAULT_SOAP_PROTOCOL.equals(protocol)
+ || SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)
+ || SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)){
+ SAAJMetaFactory saajMetaFactory = SAAJMetaFactory.getInstance();
+ return saajMetaFactory.newSOAPFactory(protocol);
}else{
- return null;
+ throw new SOAPException("Unknown protocol :"+protocol);
}
} catch (Exception exception) {
throw new SOAPException("Unable to create SOAP Factory: "
@@ -181,9 +176,24 @@
}
}
+ /**
+ * Creates a SOAPElement object from an existing DOM Element. If the DOM Element that is
+ * passed in as an argument is already a SOAPElement then this method must return it unmodified
+ * without any further work. Otherwise, a new SOAPElement is created and a deep copy is made of
+ * the domElement argument. The concrete type of the return value will depend on the name of
+ * the domElement argument. If any part of the tree rooted in domElement violates SOAP rules,
+ * a SOAPException will be thrown.
+ *
+ * @param domElement - the Element to be copied.
+ * @return a new SOAPElement that is a copy of domElement.
+ * @throws SOAPException - if there is an error in creating the SOAPElement object
+ * @since SAAJ 1.3
+ * @see SOAPFactoryImpl
+ */
public SOAPElement createElement(org.w3c.dom.Element element)
throws SOAPException {
- throw new UnsupportedOperationException("Not yet implemented");
+ //see SOAPFactoryImpl
+ return null;
}
@@ -196,22 +206,11 @@
* @param qname - a QName object with the XML name for the new element
* @return the new SOAPElement object that was created
* @throws SOAPException - if there is an error in creating the SOAPElement object
+ * @see SOAPFactoryImpl
*/
public SOAPElement createElement(javax.xml.namespace.QName qname)
throws SOAPException {
- //throw new UnsupportedOperationException("Not yet implemented");
- //TODO : check
- String localName = qname.getLocalPart();
- String prefix = qname.getPrefix();
- String uri = qname.getNamespaceURI();
-
- //TODO: WIP
-
- //OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
return null;
- //dependancy would create a cyclic reference
- //return new SOAPElementImpl((ElementImpl) omElement);
-
}
public abstract SOAPFault createFault()
Modified: webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFault.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFault.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFault.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj-api/src/javax/xml/soap/SOAPFault.java Wed Jan 31 12:35:21 2007
@@ -209,7 +209,7 @@
*/
public abstract Locale getFaultStringLocale();
- public abstract void addFaultReasonText(java.lang.String s,
+ public abstract void addFaultReasonText(java.lang.String reasonText,
java.util.Locale locale)
throws SOAPException;
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/AttachmentPartImpl.java Wed Jan 31 12:35:21 2007
@@ -15,12 +15,12 @@
*/
package org.apache.axis2.saaj;
-import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
-import org.apache.axiom.om.impl.dom.DocumentImpl;
-import org.apache.axiom.om.impl.dom.TextImpl;
-import org.apache.axis2.saaj.util.SAAJDataSource;
-import org.apache.axis2.transport.http.HTTPConstants;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.Iterator;
import javax.activation.DataHandler;
import javax.activation.UnsupportedDataTypeException;
@@ -29,10 +29,13 @@
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
import javax.xml.transform.stream.StreamSource;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
+
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
+import org.apache.axiom.om.impl.dom.DocumentImpl;
+import org.apache.axiom.om.impl.dom.TextImpl;
+import org.apache.axis2.saaj.util.SAAJDataSource;
+import org.apache.axis2.transport.http.HTTPConstants;
/**
*
@@ -160,8 +163,12 @@
}
try {
String contentType = dataHandler.getContentType();
- if (contentType.equals("text/plain") ||
- contentType.equals("text/xml") ||
+ //TODO change to text/xml
+ if(contentType.equals("text/xml")){
+ StringReader stringReader = new StringReader((String)dataHandler.getContent());
+ StreamSource streamSource = new StreamSource(stringReader);
+ return streamSource;
+ }else if (contentType.equals("text/plain") ||
contentType.equals("text/html")) {
//For these content types underlying DataContentHandler surely does
@@ -220,8 +227,9 @@
}
} else if (object instanceof java.io.InputStream) {
try {
- source = new SAAJDataSource((java.io.InputStream) object,
- SAAJDataSource.MAX_MEMORY_DISK_CACHED,
+
+ source = new SAAJDataSource((java.io.InputStream) object,
+ SAAJDataSource.MIN_MEMORY_DISK_CACHED,
contentType, true);
extractFilename(source);
dataHandler = new DataHandler(source);
@@ -240,7 +248,24 @@
} catch (java.io.IOException io) {
throw new java.lang.IllegalArgumentException("Illegal Argument");
}
- } else {
+ }else if (object instanceof BufferedImage) {
+ try {
+ dataHandler = new DataHandler(object,contentType);
+ contentObject = null; // the stream has been consumed
+ } catch (Exception e) {
+ throw new java.lang.IllegalArgumentException(e);
+ }
+ }
+ /*
+ else if (object instanceof byte[]) {
+ try {
+ dataHandler = new DataHandler();
+ contentObject = null; // the stream has been consumed
+ } catch (Exception e) {
+ throw new java.lang.IllegalArgumentException(e);
+ }
+ }*/
+ else {
throw new java.lang.IllegalArgumentException("Illegal Argument");
}
}
@@ -408,7 +433,7 @@
public InputStream getBase64Content() throws SOAPException {
try {
if (dataHandler == null) {
- return null;
+ throw new SOAPException();
}
return dataHandler.getInputStream();
} catch (IOException e) {
@@ -416,10 +441,25 @@
}
}
+
+ /**
+ * Gets the content of this AttachmentPart object as an InputStream as if a call had been made
+ * to getContent and no DataContentHandler had been registered for the content-type of this
+ * AttachmentPart.Note that reading from the returned InputStream would result in consuming
+ * the data in the stream. It is the responsibility of the caller to reset the InputStream
+ * appropriately before calling a Subsequent API. If a copy of the raw attachment content is
+ * required then the getRawContentBytes() API should be used instead.
+ *
+ * @return an InputStream from which the raw data contained by the AttachmentPart can be
+ * accessed.
+ * @throws SOAPException - if there is no content set into this AttachmentPart object or if
+ * there was a data transformation error.
+ * @since SAAJ 1.3
+ */
public InputStream getRawContent() throws SOAPException {
try {
if (dataHandler == null) {
- return null;
+ throw new SOAPException("No content set");
}
return dataHandler.getInputStream();
} catch (IOException e) {
@@ -427,9 +467,19 @@
}
}
+ /**
+ * Gets the content of this AttachmentPart object as a byte[] array as if a call had been made
+ * to getContent and no DataContentHandler had been registered for the content-type of this
+ * AttachmentPart.
+ *
+ * @return a byte[] array containing the raw data of the AttachmentPart.
+ * @throws SOAPException - if there is no content set into this AttachmentPart object or if
+ * there was a data transformation error.
+ * @since SAAJ 1.3
+ */
public byte[] getRawContentBytes() throws SOAPException {
if (dataHandler == null) {
- return null;
+ throw new SOAPException("Content is null");
}
ByteArrayOutputStream bout = new ByteArrayOutputStream();
try {
@@ -440,16 +490,92 @@
return bout.toByteArray();
}
- public void setBase64Content(InputStream inputstream, String s) throws SOAPException {
- //TODO - Not yet implemented
- }
-
- public void setRawContent(InputStream inputstream, String s) throws SOAPException {
- //TODO - Not yet implemented
- }
-
- public void setRawContentBytes(byte[] abyte0, int i, int j, String s) throws SOAPException {
- //TODO - Not yet implemented
+
+ /**
+ * Sets the content of this attachment part from the Base64 source InputStream and sets the
+ * value of the Content-Type header to the value contained in contentType, This method would
+ * first decode the base64 input and write the resulting raw bytes to the attachment.
+ * A subsequent call to getSize() may not be an exact measure of the content size.
+ *
+ * @param content - the base64 encoded data to add to the attachment part
+ * contentType - the value to set into the Content-Type header
+ * @throws SOAPException - if there is an error in setting the content
+ * java.lang.NullPointerException - if content is null
+ */
+ public void setBase64Content(InputStream content, String contentType) throws SOAPException {
+ if(content == null){
+ throw new SOAPException("Content is null");
+ }
+ try {
+ if(isValidBase64Encoding(content)){
+ setContent(content, contentType);
+ }else{
+ throw new SOAPException("Not a valid Base64 encoding");
+ }
+ } catch (Exception ex) {
+ throw new SOAPException(ex);
+ }
+ }
+
+ /*
+ * check if the given InputStream contains valid Base64 Encoding
+ */
+ private boolean isValidBase64Encoding (InputStream content) {
+ //TODO need to add more checks
+ int size;
+ try {
+ size = content.available();
+ if (size%4 != 0){
+ //Length of Base64 encoded input string is not a multiple of 4
+ return false;
+ }else{
+ return true;
+ }
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Sets the content of this attachment part to that contained by the InputStream content and
+ * sets the value of the Content-Type header to the value contained in contentType.A subsequent
+ * call to getSize() may not be an exact measure of the content size.
+ *
+ * @param content - the raw data to add to the attachment part
+ * contentType - the value to set into the Content-Type header
+ * @throws SOAPException - if there is an error in setting the content
+ * java.lang.NullPointerException - if content is null
+ *
+ */
+ public void setRawContent(InputStream content, String contentType) throws SOAPException {
+ //TODO check
+ if(content == null){
+ //throw new NullPointerException("content is null");
+ throw new SOAPException("content is null");
+ }
+ setContent(content, contentType);
+ }
+
+
+ /**
+ * Sets the content of this attachment part to that contained by the byte[] array content and
+ * sets the value of the Content-Type header to the value contained in contentType.
+ *
+ * @param content - the raw data to add to the attachment part
+ * contentType - the value to set into the Content-Type header
+ * offset - the offset in the byte array of the content
+ * len - the number of bytes that form the content
+ * @throws SOAPException - if an there is an error in setting the content or content is null
+ * @since SAAJ 1.3
+ *
+ */
+
+ public void setRawContentBytes(byte[] content, int offset, int len, String contentType) throws SOAPException {
+ //TODO - complete
+ if(content == null){
+ throw new SOAPException("Content is null");
+ }
+
}
/**
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/DetailImpl.java Wed Jan 31 12:35:21 2007
@@ -99,8 +99,17 @@
return details.iterator();
}
+ /**
+ * Creates a new DetailEntry object with the given name and adds it to this Detail object.
+ * @param name - a Name object identifying the new DetailEntry object
+ * @throws SOAPException - thrown when there is a problem in adding a DetailEntry object to this
+ * Detail object.
+ */
public DetailEntry addDetailEntry(QName qname) throws SOAPException {
- return null; //TODO: Fixme.
+ SOAPElementImpl childElement = (SOAPElementImpl) addChildElement(qname);
+ DetailEntryImpl detailEntry = new DetailEntryImpl(childElement.element);
+ childElement.element.setUserData(SAAJ_NODE, detailEntry, null);
+ return detailEntry;
}
public SOAPElement addAttribute(QName qname, String value) throws SOAPException {
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/MessageFactoryImpl.java Wed Jan 31 12:35:21 2007
@@ -126,6 +126,8 @@
*
* @return a new <CODE>SOAPMessage</CODE> object
* @throws SOAPException if a SOAP error occurs
+ * java.lang.UnsupportedOperationException - if the protocol of this
+ * MessageFactory instance is DYNAMIC_SOAP_PROTOCOL
*/
public SOAPMessage createMessage() throws SOAPException {
SOAPEnvelopeImpl soapEnvelope;
@@ -133,7 +135,10 @@
soapEnvelope =
new SOAPEnvelopeImpl((org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)
new SOAP12Factory().getDefaultEnvelope());
- } else {
+ }else if(soapVersion.equals(SOAPConstants.DYNAMIC_SOAP_PROTOCOL)){
+ throw new UnsupportedOperationException("createMessage() is not supported for DYNAMIC_SOAP_PROTOCOL");
+ }else {
+ //SOAP 1.1
soapEnvelope =
new SOAPEnvelopeImpl((org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)
new SOAP11Factory().getDefaultEnvelope());
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/PrefixedQName.java Wed Jan 31 12:35:21 2007
@@ -116,7 +116,9 @@
if (!qName.equals(((PrefixedQName) obj).qName)) {
return false;
}
- return prefix.equals(((PrefixedQName) obj).prefix);
+ return true;
+ //Is this correct?
+ //return prefix.equals(((PrefixedQName) obj).prefix);
}
public int hashCode() {
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPBodyImpl.java Wed Jan 31 12:35:21 2007
@@ -44,8 +44,11 @@
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
import org.apache.axiom.soap.impl.dom.soap11.SOAP11FaultImpl;
+import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderBlockImpl;
import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
import org.apache.axiom.soap.impl.dom.soap12.SOAP12FaultImpl;
+import org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderBlockImpl;
+import org.apache.axis2.namespace.Constants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -376,11 +379,17 @@
//TODO - check
Iterator childElements = this.getChildElements();
org.w3c.dom.Node domNode = null;
+ int childCount = 0;
while (childElements.hasNext()) {
domNode = (org.w3c.dom.Node) childElements.next();
- break;
+ childCount++;
+ if(childCount > 1){
+ throw new SOAPException("SOAPBody contains more than one child element");
+ }
}
-
+ //The child SOAPElement is removed as part of the process
+ this.removeContents();
+
Document document;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -389,12 +398,12 @@
try {
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.newDocument();
- Element element = document.createElement(domNode.getLocalName());
+ //Element element = document.createElement(domNode.getLocalName());
//TODO: WIP
//element.setAttribute(domNode.getNodeName(), domNode.getNodeValue());
- //Element element = document.createElementNS(domNode.getNamespaceURI(), domNode.getLocalName());
- //element.setNodeValue(domNode.getNodeValue());
- //document.appendChild(domNode);
+ Element element = document.createElementNS(domNode.getNamespaceURI(), domNode.getLocalName());
+ element.setNodeValue(domNode.getNodeValue());
+ document.appendChild(element);
} catch (ParserConfigurationException e) {
@@ -510,8 +519,20 @@
}
public QName createQName(String localName, String prefix) throws SOAPException {
- //TODO : check
- return super.createQName(localName, prefix);
+ if (this.element.getOMFactory() instanceof SOAP11Factory) {
+ return super.createQName(localName, prefix);
+ }
+ else if(this.element.getOMFactory() instanceof SOAP12Factory) {
+ {
+ if(this.element.findNamespaceURI(prefix) == null){
+ throw new SOAPException("Only Namespace Qualified elements are allowed");
+ }else{
+ return super.createQName(localName, prefix);
+ }
+ }
+ }else{
+ throw new UnsupportedOperationException();
+ }
}
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java Wed Jan 31 12:35:21 2007
@@ -15,14 +15,35 @@
*/
package org.apache.axis2.saaj;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.impl.llom.OMTextImpl;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
-import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.OperationClient;
import org.apache.axis2.client.Options;
@@ -30,27 +51,10 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.saaj.util.IDGenerator;
import org.apache.axis2.saaj.util.SAAJUtil;
+import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import javax.xml.soap.AttachmentPart;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPHeaderElement;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.soap.SOAPPart;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
/**
*
*/
@@ -368,6 +372,36 @@
return null;
}
+ /**
+ * overrided SOAPConnection's get() method
+ */
+
+ public SOAPMessage get(Object to) throws SOAPException {
+ URL url = null;
+ try
+ {
+ url = (to instanceof URL) ? (URL) to : new URL(to.toString());
+ if(url != null){
+ InputStream in = url.openStream();
+ //TODO : setting null for mime headers
+ // close the connection??
+ SOAPMessage soapMessage = new SOAPMessageImpl(in,null);
+ return soapMessage;
+ }
+ return null;
+ }catch (MalformedURLException e) {
+ throw new SOAPException(e);
+ }catch (IOException e) {
+ throw new SOAPException(e);
+ }catch (OMException e){
+ throw new SOAPException(e);
+ }
+
+ }
+
+
+
+
/* private void printOMSOAPEnvelope(final org.apache.axiom.soap.SOAPEnvelope omSOAPEnv) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPElementImpl.java Wed Jan 31 12:35:21 2007
@@ -31,13 +31,17 @@
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
+import org.apache.axiom.om.impl.OMNamespaceImpl;
import org.apache.axiom.om.impl.dom.DocumentImpl;
import org.apache.axiom.om.impl.dom.ElementImpl;
import org.apache.axiom.om.impl.dom.NodeImpl;
import org.apache.axiom.om.impl.dom.TextImpl;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
+import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderBlockImpl;
+import org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderBlockImpl;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
@@ -398,8 +402,24 @@
return addChildElement(qname.getLocalPart(), "".equals(prefix) ? null : prefix , qname.getNamespaceURI());
}
+ /**
+ * Creates a QName whose namespace URI is the one associated with the parameter, prefix,
+ * in the context of this SOAPElement. The remaining elements of the new QName are taken
+ * directly from the parameters, localName and prefix.
+ *
+ * @param localName - a String containing the local part of the name.
+ * prefix - a String containing the prefix for the name.
+ * @return a QName with the specified localName and prefix, and with a namespace that is
+ * associated with the prefix in the context of this SOAPElement. This namespace will
+ * be the same as the one that would be returned by getNamespaceURI(String) if it
+ * were given prefix as its parameter.
+ * @throws SOAPException - if the QName cannot be created.
+ * @since SAAJ 1.3
+ */
public QName createQName(String localName, String prefix) throws SOAPException {
- //TODO - check
+ if(this.element.getNamespaceURI(prefix) == null){
+ throw new SOAPException("Invalid prefix");
+ }
QName qname = null;
if(SOAPConstants.SOAP_1_1_PROTOCOL.equals(getSOAPVersion(this.element))){
qname = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,localName,prefix);
@@ -461,6 +481,14 @@
public SOAPElement setElementQName(QName newName) throws SOAPException {
//TODO - check
+ String localName = this.element.getLocalName();
+ if(org.apache.axiom.soap.SOAPConstants.BODY_LOCAL_NAME.equals(localName)
+ || org.apache.axiom.soap.SOAPConstants.HEADER_LOCAL_NAME.equals(localName)
+ || org.apache.axiom.soap.SOAPConstants.SOAPENVELOPE_LOCAL_NAME .equals(localName)){
+ throw new SOAPException("changing this element name is not allowed");
+ }
+ OMNamespace omNamespace = new OMNamespaceImpl(newName.getNamespaceURI(),newName.getPrefix());
+ this.element.setNamespace(omNamespace);
this.element.setLocalName(newName.getLocalPart());
return this;
}
@@ -484,14 +512,13 @@
*/
public void removeContents() {
//We will get all the children and iteratively call the detach() on all of 'em.
- Iterator childIter = element.getChildren();
-
- while (childIter.hasNext()) {
- Object o = childIter.next();
- if (o instanceof org.apache.axiom.om.OMNode) {
- ((org.apache.axiom.om.OMNode) o).detach();
- }
- }
+ Iterator childIter = element.getChildElements();
+ while (childIter.hasNext()) {
+ Object o = childIter.next();
+ if (o instanceof org.apache.axiom.om.OMNode) {
+ ((org.apache.axiom.om.OMNode) o).detach();
+ }
+ }
}
/* (non-Javadoc)
@@ -507,9 +534,10 @@
//TODO : jira issue
public void setEncodingStyle(String encodingStyle) throws SOAPException {
- if (!encodingStyle.equals(SOAPConstants.URI_NS_SOAP_ENCODING)) {
- throw new IllegalArgumentException("Invalid Encoding style : " + encodingStyle);
- }
+ //TODO : is this check correct?
+ //if (!encodingStyle.equals(SOAPConstants.URI_NS_SOAP_ENCODING)) {
+ // throw new IllegalArgumentException("Invalid Encoding style : " + encodingStyle);
+ //}
((DocumentImpl) getOwnerDocument()).setCharsetEncoding(encodingStyle);
}
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPEnvelopeImpl.java Wed Jan 31 12:35:21 2007
@@ -15,23 +15,24 @@
*/
package org.apache.axis2.saaj;
-import org.apache.axiom.soap.SOAPFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+
import org.apache.axiom.om.impl.dom.DocumentImpl;
import org.apache.axiom.om.impl.dom.NodeImpl;
import org.apache.axiom.om.impl.dom.TextImpl;
+import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.impl.dom.soap11.SOAP11BodyImpl;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderImpl;
import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
+import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderImpl;
+import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
import org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderImpl;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPHeader;
-
/**
*
*/
@@ -222,4 +223,48 @@
}
return this;
}
+
+ /**
+ * Override SOAPElementImpl.setEncodingStyle
+ */
+ public void setEncodingStyle(String encodingStyle) throws SOAPException {
+ if(this.element.getOMFactory() instanceof SOAP12Factory) {
+ throw new SOAPException("SOAP1.2 does not allow encodingStyle to be set on Envelope");
+ }else{
+ super.setEncodingStyle(encodingStyle);
+ }
+ }
+
+ /**
+ * Override SOAPElement.addAttribute
+ * SOAP1.2 should not allow encodingStyle attribute to be set on Envelop
+ */
+ public SOAPElement addAttribute(Name name, String value) throws SOAPException {
+ if(this.element.getOMFactory() instanceof SOAP12Factory) {
+ if("encodingStyle".equals(name.getLocalName())){
+ throw new SOAPException("SOAP1.2 does not allow encodingStyle attribute to be set " +
+ "on Envelope");
+ }
+ }
+ return super.addAttribute(name, value);
+ }
+
+ /**
+ * Override SOAPElement.addChildElement
+ * SOAP 1.2 should not allow element to be added after body element
+ */
+ public SOAPElement addChildElement(Name name) throws SOAPException {
+ //TODO : complete
+ if(this.element.getOMFactory() instanceof SOAP12Factory) {
+ //return super.addChildElement(name);
+ throw new SOAPException("Cannot add elements after body element");
+ }else if(this.element.getOMFactory() instanceof SOAP11Factory){
+ //Let elements to be added any where.
+ return super.addChildElement(name);
+ }
+ return null;
+ }
+
+
+
}
Modified: webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java?view=diff&rev=501978&r1=501977&r2=501978
==============================================================================
--- webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java (original)
+++ webservices/axis2/branches/java/maven2/modules/saaj/src/org/apache/axis2/saaj/SOAPFactoryImpl.java Wed Jan 31 12:35:21 2007
@@ -31,6 +31,7 @@
import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
import org.apache.axiom.om.impl.dom.ElementImpl;
import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.w3c.dom.Element;
/**
*
@@ -173,7 +174,15 @@
*/
public SOAPFault createFault() throws SOAPException {
//TODO - check
- return new SOAPFaultImpl(DOOMAbstractFactory.getSOAP11Factory().createSOAPFault());
+ OMDOMFactory omdomFactory = null;
+ org.apache.axiom.soap.SOAPFactory soapFactory;
+ if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
+ soapFactory = DOOMAbstractFactory.getSOAP12Factory();
+ return new SOAPFaultImpl(soapFactory.createSOAPFault());
+ } else {
+ soapFactory = DOOMAbstractFactory.getSOAP11Factory();
+ return new SOAPFaultImpl(soapFactory.createSOAPFault());
+ }
}
/**
@@ -186,14 +195,43 @@
*/
public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException {
//TODO - check
- //using english as the default locale
- SOAPFault soapFault = new SOAPFaultImpl(DOOMAbstractFactory.getSOAP11Factory().createSOAPFault());
+ SOAPFault soapFault;
+ if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
+ soapFault = new SOAPFaultImpl(DOOMAbstractFactory.getSOAP12Factory().createSOAPFault());
+ } else {
+ soapFault = new SOAPFaultImpl(DOOMAbstractFactory.getSOAP11Factory().createSOAPFault());
+ }
soapFault.setFaultCode(faultCode);
- soapFault.addFaultReasonText(reasonText, Locale.ENGLISH);
+ soapFault.addFaultReasonText(reasonText, Locale.getDefault());
return soapFault;
}
public void setSOAPVersion(String soapVersion){
this.soapVersion = soapVersion;
}
+
+
+ public SOAPElement createElement(QName qname) throws SOAPException {
+ String localName = qname.getLocalPart();
+ String prefix = qname.getPrefix();
+ String uri = qname.getNamespaceURI();
+ OMElement omElement = DOOMAbstractFactory.getOMFactory().createOMElement(localName, uri, prefix);
+ return new SOAPElementImpl((ElementImpl) omElement);
+ }
+
+ public SOAPElement createElement(Element element) throws SOAPException {
+ OMDOMFactory omdomFactory = null;
+ if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
+ omdomFactory = (OMDOMFactory) DOOMAbstractFactory.getSOAP12Factory();
+ } else {
+ omdomFactory = (OMDOMFactory) DOOMAbstractFactory.getSOAP11Factory();
+ }
+ OMNamespace ns = omdomFactory.createOMNamespace(element.getNamespaceURI(),element.getPrefix());
+ OMElement omElement = omdomFactory.createOMElement(element.getLocalName(), ns);
+ return new SOAPElementImpl((ElementImpl) omElement);
+ }
+
+
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org