You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/12/27 19:21:15 UTC
svn commit: r359257 - in /beehive/trunk/wsm:
src/axis/org/apache/beehive/wsm/axis/ src/core/org/apache/beehive/wsm/util/
test/src/junit-services/org/apache/beehive/wsm/axis/
test/src/junit-services/org/apache/beehive/wsm/axis/beans/
test/src/junit/org/...
Author: ekoneil
Date: Tue Dec 27 10:21:08 2005
New Revision: 359257
URL: http://svn.apache.org/viewcvs?rev=359257&view=rev
Log:
WSM changes:
- thoroughly document the ServiceDescriptionFactory class in an attempt to comprehend what it's doing
- update tests in QNameToClassTest. Need to explicitly support SOAP encoding tests here
- move all of the constants from SchemaTypesLookupStrategy to TypeMappingConstants
- make comprehensible names in the WSM tests
BB: self
Test: WSM && WSC pass
Added:
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/TypeMappingConstants.java (with props)
beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ComplexJavaBean.java (contents, props changed)
- copied, changed from r358086, beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ModeratelyComplexObject.java
Removed:
beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ModeratelyComplexObject.java
Modified:
beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java
beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/SchemaTypesLookupStrategy.java
beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeDocWebService.java
beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeRpcWebService.java
beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/EndpointInterfaceServiceTest.java
beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/types/QNameToClassTest.java
Modified: beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java?rev=359257&r1=359256&r2=359257&view=diff
==============================================================================
--- beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java (original)
+++ beehive/trunk/wsm/src/axis/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java Tue Dec 27 10:21:08 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,12 @@
package org.apache.beehive.wsm.axis;
import java.io.File;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.rmi.Remote;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.Iterator;
import javax.jws.WebParam;
import javax.jws.soap.SOAPBinding;
import javax.wsdl.OperationType;
@@ -40,8 +39,6 @@
import org.apache.axis.description.ParameterDesc;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.description.TypeDesc;
-import org.apache.axis.encoding.DeserializerFactory;
-import org.apache.axis.encoding.SerializerFactory;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.TypeMappingRegistry;
import org.apache.axis.encoding.TypeMappingRegistryImpl;
@@ -64,19 +61,19 @@
import org.apache.beehive.wsm.exception.InvalidTypeMappingException;
import org.apache.beehive.wsm.util.JavaClassUtils;
import org.apache.beehive.wsm.util.TypeUtils;
+import org.apache.beehive.wsm.util.TypeMappingConstants;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.apache.xmlbeans.XmlBeans;
import org.apache.xmlbeans.XmlObject;
/**
- * This class is used from the AnnotatedWebServiceDeploymentHandler to produce an Axis
- * {@link ServiceDesc} object. The service description is built from the description
- * of a JSR-181 compliant annotated web service.
+ * This class is used to configure an Axis ServiceDesc object which represents a web service in Axis. The ServiceDesc
+ * is created by using the WSM metadata classes created during processing of JSR-181 metadata.
*/
public final class ServiceDescriptionFactory {
- private static Log LOGGER = LogFactory.getLog(ServiceDescriptionFactory.class);
+ private static Log LOG = LogFactory.getLog(ServiceDescriptionFactory.class);
public static ServiceDescriptionFactory getInstance() {
return new ServiceDescriptionFactory();
@@ -85,42 +82,56 @@
/* Do not construct */
private ServiceDescriptionFactory() {}
- public ServiceDesc createServiceDescription(BeehiveWsTypeMetadata wsm, ClassLoader cl)
+ public ServiceDesc createServiceDescription(BeehiveWsTypeMetadata wsmServiceDesc, ClassLoader classLoader)
throws ClassNotFoundException, InvalidTypeMappingException {
- JavaServiceDesc sd = new JavaServiceDesc();
+ JavaServiceDesc axisServiceDesc = new JavaServiceDesc();
+
/*
- If no classloader was provided, use the one that loaded this Class
+ If no classloader was provided, default to using the one that loaded this Class
*/
- if(cl == null)
- cl = ServiceDescriptionFactory.class.getClassLoader();
+ if(classLoader == null)
+ classLoader = ServiceDescriptionFactory.class.getClassLoader();
- final Class serviceClass = cl.loadClass(wsm.getServiceClassName());
+ /*
+ The web service's implementation class
+ */
+ final Class serviceClass = classLoader.loadClass(wsmServiceDesc.getServiceClassName());
/*
Create a list of the allowed methods
*/
- List<String> allowedMethods = new ArrayList<String>();
- for(BeehiveWsMethodMetadata meth : wsm.getMethods()) {
+ ArrayList<String> allowedMethods = new ArrayList<String>();
+ for(BeehiveWsMethodMetadata meth : wsmServiceDesc.getMethods()) {
String method = meth.getJavaMethodName();
allowedMethods.add(method);
}
+ /* configure the basic Axis ServiceDesc object */
+ axisServiceDesc.setName(wsmServiceDesc.getName());
+ axisServiceDesc.setImplClass(serviceClass);
+
+ String targetNamespace = wsmServiceDesc.getTargetNamespace();
+ axisServiceDesc.setDefaultNamespace(targetNamespace);
+ axisServiceDesc.setAllowedMethods(allowedMethods);
+
+ configureSoapBinding(axisServiceDesc, wsmServiceDesc.getSoapBinding());
+
/*
- set the ServiceDesc base information
+ Configure the type mappings used for this web service. Note, this requires that the
+ ServiceDesc's "use" property has already been configured.
*/
- sd.setName(wsm.getName());
- sd.setImplClass(serviceClass);
+ TypeMappingRegistry axisTypeMappingRegistry = new TypeMappingRegistryImpl(true);
+ TypeMapping axisTypeMapping;
- String targetNamespace = wsm.getTargetNamespace();
- sd.setDefaultNamespace(targetNamespace);
- sd.setAllowedMethods(allowedMethods);
- configureSoapBinding(sd, wsm.getSoapBinding());
-
- TypeMappingRegistry tmr = new TypeMappingRegistryImpl(true);
- TypeMapping tm = tmr.getOrMakeTypeMapping(sd.getUse() == Use.ENCODED ? "http://schemas.xmlsoap.org/soap/encoding/" : "");
- sd.setTypeMappingRegistry(tmr);
- sd.setTypeMapping(tm);
+ /* configure the base type mapping registry used for this service based on the service's encoding type */
+ Use use = axisServiceDesc.getUse();
+ if(use == Use.ENCODED)
+ axisTypeMapping = axisTypeMappingRegistry.getOrMakeTypeMapping(TypeMappingConstants.URI_SOAP11_ENC);
+ else axisTypeMapping = axisTypeMappingRegistry.getOrMakeTypeMapping("");
+
+ axisServiceDesc.setTypeMappingRegistry(axisTypeMappingRegistry);
+ axisServiceDesc.setTypeMapping(axisTypeMapping);
/*
* jongjinchoi@apache.org 2005-Mar-16 -- Use Axis's introspection
@@ -130,46 +141,49 @@
* fills the ParameterDesc's typeEntry from the preset typemapping
* registry, which is required for Axis to work in wrapped/lit mode.
*/
- sd.getOperations();
+ /* todo: does this configure the service correctly? */
+ axisServiceDesc.getOperations();
- Collection<? extends BeehiveWsMethodMetadata> methods = wsm.getMethods();
- for(BeehiveWsMethodMetadata meth : methods) {
- String operationName = meth.getWmOperationName();
+ BeehiveWsMethodMetadata[] wsmOperationDescs = wsmServiceDesc.getMethods().toArray(new BeehiveWsMethodMetadata[0]);
+ for(int i = 0; i < wsmOperationDescs.length; i++) {
+ BeehiveWsMethodMetadata wsmOperationDesc = wsmOperationDescs[i];
+ String operationName = wsmOperationDesc.getWmOperationName();
- OperationDesc od = getOperationDesc(sd, meth);
- assert od != null : "Can not find method: " + operationName + " in webservice";
+ OperationDesc axisOperationDesc = getOperationDesc(axisServiceDesc, wsmOperationDesc);
+ assert axisOperationDesc != null : "Can not find method: " + operationName + " in webservice";
/*
- Configure web method info
+ Configure the method. This uses a combination of the metadata processed from a WSM
+ interface / implementation to further configure an Axis OperationDesc object.
*/
- od.setElementQName(new QName(targetNamespace, operationName));
- od.setName(operationName);
- od.setSoapAction(meth.getWmAction());
- if(meth.isOneWay()) {
- od.setMep(OperationType.ONE_WAY);
- }
+ axisOperationDesc.setElementQName(new QName(targetNamespace, operationName));
+ axisOperationDesc.setName(operationName);
+ axisOperationDesc.setSoapAction(wsmOperationDesc.getWmAction());
+
+ if(wsmOperationDesc.isOneWay())
+ axisOperationDesc.setMep(OperationType.ONE_WAY);
else {
String namespace = "";
/*
namespace only should be added for document style,
RPC style doesn't need name space for return type.
*/
- if(wsm.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT)
- namespace = meth.getWrTargetNamespace();
+ if(wsmServiceDesc.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT)
+ namespace = wsmOperationDesc.getWrTargetNamespace();
- od.setReturnQName(new QName(namespace, meth.getWrName()));
+ axisOperationDesc.setReturnQName(new QName(namespace, wsmOperationDesc.getWrName()));
QName qn = null;
- QName odReturnType = od.getReturnType();
- final Class returnType = createClass(meth.getJavaReturnType());
+ QName odReturnType = axisOperationDesc.getReturnType();
+ final Class returnType = createClass(wsmOperationDesc.getJavaReturnType());
/*
if we are processing an rpc encoded service, and the qname of the return type
from the operation desc has a name space uri of soapenc, there is no need to
call configureTypeMapping since we already know the type.
*/
- if(wsm.getSoapBinding().getStyle() == SOAPBinding.Style.RPC &&
- wsm.getSoapBinding().getUse() == SOAPBinding.Use.ENCODED) {
+ BeehiveWsSOAPBindingInfo wsmSoapBinding = wsmServiceDesc.getSoapBinding();
+ if(wsmSoapBinding.getStyle() == SOAPBinding.Style.RPC && wsmSoapBinding.getUse() == SOAPBinding.Use.ENCODED) {
if(odReturnType != null
&& !returnType.isArray()
@@ -183,107 +197,144 @@
type = type.getComponentType();
}
- if (isActivationEnabled() && java.awt.Image.class.isAssignableFrom(type)) {
- ; // do nothing - axis will have already set value correctly
+ if(isActivationEnabled() && java.awt.Image.class.isAssignableFrom(type)) {
+ /* no-op: Axis will have already set value correctly */
}
else if (isActivationEnabled() && getDataHandlerClass().isAssignableFrom(type)) {
- ; // do nothing - axis will have already set value correctly
+ /* no-op: Axis will have already set the value correctly */
}
else {
- qn = configureTypeMapping(sd, returnType, meth.getWrTargetNamespace());
- od.setReturnType(qn);
- od.setReturnClass(returnType);
+ qn = configureTypeMapping(axisServiceDesc, returnType, wsmOperationDesc.getWrTargetNamespace());
+ axisOperationDesc.setReturnType(qn);
+ axisOperationDesc.setReturnClass(returnType);
}
}
- if (wsm.getSoapBinding().getStyle() == SOAPBinding.Style.RPC && returnType.isArray())
- od.getReturnParamDesc().setItemQName(new QName("","item"));
+ if (wsmServiceDesc.getSoapBinding().getStyle() == SOAPBinding.Style.RPC && returnType.isArray())
+ axisOperationDesc.getReturnParamDesc().setItemQName(new QName("", "item"));
}
/*
- Configure method parameters
+ Configure method parameters. This uses a combination of the metadata processed from the
+ service interface / implementation to further configure the parameters Axis has already
+ configured.
*/
- int pcnt = 0;
- for(BeehiveWsParameterMetadata param : meth.getParams()) {
- ParameterDesc pd = od.getParameter(pcnt++);
+ BeehiveWsParameterMetadata[] wsmParameterDescs = wsmOperationDesc.getParams().toArray(new BeehiveWsParameterMetadata[0]);
+ for(int j = 0; j < wsmParameterDescs.length; j++) {
+ BeehiveWsParameterMetadata wsmParameterDesc = wsmParameterDescs[j];
+ ParameterDesc axisParameterDesc = axisOperationDesc.getParameter(j);
- final Class paramType = createClass(param.getJavaType());
+ final Class paramType = createClass(wsmParameterDesc.getJavaType());
- if(pd.getTypeQName() == null) {
+ if(axisParameterDesc.getTypeQName() == null) {
/* set the typeQName if it is not set already */
- QName typeQName = configureTypeMapping(sd, paramType, param.getWpTargetNamespace());
+ QName typeQName = configureTypeMapping(axisServiceDesc, paramType, wsmParameterDesc.getWpTargetNamespace());
/*
jongjinchoi@apache.org 2005-Mar-16 -- The typeQName from configureTypeMapping() is not
dummy. This is required to find ArrayDeserializer when the document/literal bare array
is deserialized.
*/
- pd.setTypeQName(typeQName);
+ axisParameterDesc.setTypeQName(typeQName);
}
/* set QName */
String namespace = "";
/*
- namespace only should be added for document style, RPC style
- doesn't need name space for parameter names.
+ The namespace is only used in DOCUMENT style services. RPC services don't use the target namespace
+ for parameter names.
*/
- if(wsm.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT)
- namespace = param.getWpTargetNamespace();
+ if(wsmServiceDesc.getSoapBinding().getStyle() == SOAPBinding.Style.DOCUMENT)
+ namespace = wsmParameterDesc.getWpTargetNamespace();
- QName paramQName = new QName(namespace, param.getWpName());
- pd.setQName(paramQName);
+ QName paramQName = new QName(namespace, wsmParameterDesc.getWpName());
+ axisParameterDesc.setQName(paramQName);
- final boolean header = param.isWpHeader();
- final WebParam.Mode mode = param.getWpMode();
+ final boolean header = wsmParameterDesc.isWpHeader();
+ final WebParam.Mode mode = wsmParameterDesc.getWpMode();
switch(mode) {
case IN:
- pd.setMode(ParameterDesc.IN);
- pd.setInHeader(header);
- pd.setOutHeader(false);
+ axisParameterDesc.setMode(ParameterDesc.IN);
+ axisParameterDesc.setInHeader(header);
+ axisParameterDesc.setOutHeader(false);
break;
case OUT:
- pd.setMode(ParameterDesc.OUT);
- pd.setInHeader(false);
- pd.setOutHeader(header);
+ axisParameterDesc.setMode(ParameterDesc.OUT);
+ axisParameterDesc.setInHeader(false);
+ axisParameterDesc.setOutHeader(header);
break;
case INOUT:
- pd.setMode(ParameterDesc.INOUT);
- pd.setInHeader(header);
- pd.setOutHeader(header);
+ axisParameterDesc.setMode(ParameterDesc.INOUT);
+ axisParameterDesc.setInHeader(header);
+ axisParameterDesc.setOutHeader(header);
break;
default:
throw new IllegalArgumentException("Illegal value for WebParam.Mode: " + mode);
}
- pd.setJavaType(paramType);
+ axisParameterDesc.setJavaType(paramType);
}
/*
- Configure web method exceptions
+ Configure faults.
*/
- Method javaMethod = od.getMethod();
- boolean hasUserDefinedFaults = false;
+ Method javaMethod = axisOperationDesc.getMethod();
for(Class thrown : javaMethod.getExceptionTypes()) {
- FaultDesc fd = od.getFaultByClass(thrown);
+ FaultDesc fd = axisOperationDesc.getFaultByClass(thrown);
if(null == fd) {
String message =
"Exception: "
+ thrown.getCanonicalName()
+ " is not picked up by Axis, only non Remote and Application Specific exceptions are registed in Axis. This is not a fatal error.";
- LOGGER.warn(message);
+ LOG.warn(message);
continue;
}
- QName qname = configureTypeMapping(sd, thrown, meth.getWrTargetNamespace());
+ QName qname = configureTypeMapping(axisServiceDesc, thrown, wsmOperationDesc.getWrTargetNamespace());
fd.setXmlType(qname);
fd.setQName(qname);
fd.setComplex(true);
}
- System.out.println("========= operation description ' " + od.getName() + "'\n" + od + "\n==========\n");
+ LOG.info("========= operation description ' " + axisOperationDesc.getName() + "'\n" + axisOperationDesc + "\n==========\n");
}
- return sd;
+ return axisServiceDesc;
+ }
+
+ private void configureSoapBinding(ServiceDesc serviceDesc, BeehiveWsSOAPBindingInfo soapBindingInfo) {
+ /* default SOAP binding style info */
+ SOAPBinding.Style style = SOAPBinding.Style.DOCUMENT;
+ SOAPBinding.Use use = SOAPBinding.Use.LITERAL;
+ SOAPBinding.ParameterStyle paramStyle = SOAPBinding.ParameterStyle.WRAPPED;
+
+ /* SOAP binding was configured on the service interface / implementation */
+ if(soapBindingInfo != null) {
+ style = soapBindingInfo.getStyle();
+ use = soapBindingInfo.getUse();
+ paramStyle = soapBindingInfo.getParameterStyle();
+ }
+
+ if(style == SOAPBinding.Style.RPC) {
+ serviceDesc.setStyle(Style.RPC);
+
+ if(use == SOAPBinding.Use.ENCODED)
+ serviceDesc.setUse(Use.ENCODED);
+ else serviceDesc.setUse(Use.LITERAL);
+ }
+ else if(style == SOAPBinding.Style.DOCUMENT) {
+ /* DOCUMENT ENCODED is not valid so force to use LITERAL encoding */
+ serviceDesc.setUse(Use.LITERAL);
+
+ /* set parameter encoding style */
+ if(paramStyle == SOAPBinding.ParameterStyle.WRAPPED)
+ serviceDesc.setStyle(Style.WRAPPED);
+ else serviceDesc.setStyle(Style.DOCUMENT);
+ }
}
+ /**
+ Method used to discover an Axis OperationDesc object given a WSM representation of a web service method.
+ This uses a best-guess matching algorithm that matches the method parameter types.
+ */
private OperationDesc getOperationDesc(ServiceDesc serviceDescription, BeehiveWsMethodMetadata methodMetadata) {
assert serviceDescription != null;
assert methodMetadata != null;
@@ -327,289 +378,266 @@
}
/**
- * This method will return a boolean value indicating that Activation is
- * enabled. Activation requires the DataHandler and the Multipart Classes to
- * both be found.
- *
- * @return boolean indicating that Activation is enabled.
- */
- private boolean isActivationEnabled() {
- return null != getDataHandlerClass() && null != getMultipartClass();
- }
-
- /**
- * This will return the Class for the DataHandler. This will return null if
- * the DataHandler is not available.
- *
- * @return The DataHandler Class or null if the DataHandler is not found
- */
- private Class getDataHandlerClass() {
- try {
- return ServiceDescriptionFactory.class.getClassLoader().loadClass("javax.activation.DataHandler");
- }
- catch(ClassNotFoundException e) {
- /* todo: this should log a warning */
- }
- return null;
- }
-
- /**
- * This will return the Class for the MimeMultipart handler. It will return
- * null if the MimMultipart class is not available.
+ * Given a ServiceDescription object, determine the QName that should be used when configuring
+ * method return types, input parameter types, and fault types.
*
- * @return The MimeMultipart Class or null if the DataHandler is not found.
+ * @param axisServiceDesc the internal Axis representation of a web service
+ * @param javaType the Java class type for the parameter
+ * @param targetNamespace the target namespace for the type
+ * @return the {@link QName} that represents this type in the WSDL
+ * @throws InvalidTypeMappingException
*/
- private Class getMultipartClass() {
- try {
- return ServiceDescriptionFactory.class.getClassLoader().loadClass("javax.mail.internet.MimeMultipart");
- }
- catch(ClassNotFoundException e) {
- /* todo: this should log a warning */
- }
- return null;
- }
-
- private QName configureTypeMapping(ServiceDesc desc, Class type, String defaultNamespace)
+ private QName configureTypeMapping(ServiceDesc axisServiceDesc, Class javaType, String targetNamespace)
throws InvalidTypeMappingException {
- if(Void.TYPE.equals(type))
+ if(Void.TYPE.equals(javaType))
return null;
- /* get built-in type QName */
- QName builtInQName = AxisTypeMappingMetaData.getBuiltInTypeQname(type);
+ /* get built-in javaType QName */
+ /* todo: does this configure the QName correctly when the targetNamespace is SOAP-ENC, for example? */
+ QName builtInQName = AxisTypeMappingMetaData.getBuiltInTypeQname(javaType);
if(builtInQName != null)
return builtInQName;
- /* todo: may need to register the holder type also? */
- if(Holder.class.isAssignableFrom(type))
- type = TypeUtils.getHolderValueClass(type);
+ /*
+ If the type isn't a built-in type, the type mapping information needs to be explicitly configured
+ */
+
+ /*
+ Unwrap all Holder subclasses in order to determine the "interesting" type passed into the service
+ method
+ */
+ if(Holder.class.isAssignableFrom(javaType))
+ javaType = TypeUtils.getHolderValueClass(javaType);
- /* the type needs to be registered */
- TypeMapping tm = desc.getTypeMapping();
+ TypeMapping axisTypeMapping = axisServiceDesc.getTypeMapping();
+ /*
+ Use an Axis-specific method to lookup the Java type -> QName mapping
+ */
BindingLookupStrategy lookupStrategy = new AxisBindingLookupFactory().getInstance();
- QName qname = lookupStrategy.class2qname(type, defaultNamespace);
+ QName qname = lookupStrategy.class2qname(javaType, targetNamespace);
- if(type.isArray()) {
+ /* todo: what happens when this QName is null? */
+
+ /*
+ Support for arrays. Ensure that the array's element type is registered correctly
+ */
+ if(javaType.isArray()) {
/*
- don't register array serializer in document(bare or wrapped)/literal mode.
+ Don't register array serializer in document (bare or wrapped)/literal style.
*/
- if(!tm.isRegistered(type, qname) && desc.getStyle() == Style.RPC && desc.getUse() == Use.ENCODED) {
- tm.register(type, qname,
- new ArraySerializerFactory(type, qname),
- new ArrayDeserializerFactory());
+ if(!axisTypeMapping.isRegistered(javaType, qname) && axisServiceDesc.getStyle() == Style.RPC && axisServiceDesc.getUse() == Use.ENCODED) {
+ axisTypeMapping.register(javaType, qname,
+ new ArraySerializerFactory(javaType, qname), new ArrayDeserializerFactory());
}
- if (desc.getStyle() == Style.RPC) {
- configureTypeMapping(desc, type.getComponentType(), defaultNamespace);
+ if (axisServiceDesc.getStyle() == Style.RPC) {
+ configureTypeMapping(axisServiceDesc, javaType.getComponentType(), targetNamespace);
return XMLType.SOAP_ARRAY;
}
- QName qcomp = configureTypeMapping(desc, type.getComponentType(), defaultNamespace);
- if(desc.getUse() == Use.LITERAL)
+ QName qcomp = configureTypeMapping(axisServiceDesc, javaType.getComponentType(), targetNamespace);
+ if(axisServiceDesc.getUse() == Use.LITERAL)
qname = qcomp;
}
- else if(!tm.isRegistered(type, qname)) {
- if(XmlObject.class.isAssignableFrom(type)) {
- qname = XmlBeans.typeForClass(type).getName();
- tm.register(type, qname,
- new XmlBeanSerializerFactory(type, qname),
- new XmlBeanDeserializerFactory(type, qname));
+ /*
+ Support for XMLBeans.
+ */
+ else if(XmlObject.class.isAssignableFrom(javaType)) {
+ qname = XmlBeans.typeForClass(javaType).getName();
+ axisTypeMapping.register(javaType, qname,
+ new XmlBeanSerializerFactory(javaType, qname),
+ new XmlBeanDeserializerFactory(javaType, qname));
+ }
+ /*
+ Default case is an unregistered type. Isn't there a method in Axis that will do this automatically?
+ */
+ else if(!axisTypeMapping.isRegistered(javaType, qname)) {
+
+ /*
+ - java.rmi.Remote is prohibited by the jax-rpc spec
+ - restricting against File, since it doesn't make sense to serialize as a bean. It
+ causes an infinite loop as it keeps returning itself from the getAbsoluteFile and getCanonicalFile calls
+ */
+ if(Remote.class.isAssignableFrom(javaType) || File.class.isAssignableFrom(javaType)) {
+ throw new InvalidTypeMappingException("Unable to register "
+ + javaType.getName()
+ + " as a valid web service datatype, consider using a custom type mapping");
}
+
/*
- * NOTE jcolwell@bea.com 2004-Oct-11 -- these datahandler using
- * classes are generally already registered but just in case...
+ Get an Axis TypeDesc object that represents a configured Java <-> XML type mapping.
*/
- else if(isActivationEnabled() &&
- (java.awt.Image.class.isAssignableFrom(type)
- || getMultipartClass().isAssignableFrom(type)
- || getDataHandlerClass().isAssignableFrom(type))) {
- try {
- /*
- Use reflection here in case Axis was built without attachment support.
- */
- ClassLoader cl = ServiceDescriptionFactory.class.getClassLoader();
- /*
- cl.loadclass could have been done in import also, but if there are no activation.jar then this would
- cause error when the class is loaded. To prevent that we load the class explicitly at this point.
- if we had done the "new org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory"
- then the class would have had dependecies to the org.apache... class which would not have worked in
- case activation was not on the path.
- */
- Class<SerializerFactory> sfClass =
- (Class<SerializerFactory>)cl.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory");
- Class<DeserializerFactory> dsfClass =
- (Class<DeserializerFactory>)cl.loadClass("org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory");
- Constructor<SerializerFactory> sfCon = sfClass.getConstructor(Class.class, QName.class);
- Constructor<DeserializerFactory> dsfCon = dsfClass.getConstructor(Class.class, QName.class);
- SerializerFactory sf = sfCon.newInstance(type, qname);
- DeserializerFactory dsf = dsfCon.newInstance(type, qname);
- tm.register(type, qname, sf, dsf);
- }
- catch(Exception e) {
- LOGGER.info("Unable to find attachment serializers. Attachment support will be disabled. Cause: " + e, e);
- }
+ TypeDesc axisTypeDesc = TypeDesc.getTypeDescForClass(javaType);
+
+ /*
+ If the namespace of the axisTypeDesc object doesn't match the needed targetNamespace,
+ the TypeDesc object needs to be configured for the given namespace.
+ */
+ if(axisTypeDesc != null && !axisTypeDesc.getXmlType().getNamespaceURI().equals(qname.getNamespaceURI())) {
+ axisTypeDesc = null;
}
+
+ TypeDesc superAxisTypeDesc = null;
+ BeanPropertyDescriptor[] superPd = null;
/*
- - java.rmi.Remote is prohibited by the jax-rpc spec
- - restricting against File, since it doesn't make sense to serialize as a bean. It
- causes an infinite loop as it keeps returning itself from the getAbsoluteFile and getCanonicalFile calls
+ Configure an axisTypeDesc object given the javaType.
*/
- else if(!Remote.class.isAssignableFrom(type) && !File.class.isAssignableFrom(type)) {
- TypeDesc td = TypeDesc.getTypeDescForClass(type);
+ if(axisTypeDesc == null) {
+ axisTypeDesc = new TypeDesc(javaType);
/*
- if type was registered in a different namespace, then ignore this and create a new td
+ create javaType descriptor for this class --- NOT its super classes at this point. add super class types.
*/
- if(td != null && !td.getXmlType().getNamespaceURI().equals(qname.getNamespaceURI())) {
- td = null;
+ Class superJavaType = javaType.getSuperclass();
+ if(superJavaType != null
+ && superJavaType != java.lang.Object.class
+ && superJavaType != java.lang.Exception.class
+ && superJavaType != java.lang.Throwable.class
+ && superJavaType != java.rmi.RemoteException.class
+ && superJavaType != org.apache.axis.AxisFault.class) {
+ configureTypeMapping(axisServiceDesc, superJavaType, targetNamespace);
+ }
+
+ /* check to see if a javaType mapping was created for the super class */
+ superAxisTypeDesc = TypeDesc.getTypeDescForClass(superJavaType);
+ if(superAxisTypeDesc != null) {
+ /* super class is a regular javabean with axis typedesc */
+ superPd = superAxisTypeDesc.getPropertyDescriptors();
}
-
- TypeDesc superTd = null;
- BeanPropertyDescriptor[] superPd = null;
+ axisTypeDesc.setXmlType(qname);
+ TypeDesc.registerTypeDescForClass(javaType, axisTypeDesc);
/*
- type desc is used for java-xml mapping, make sure the class and all its super classes have a type desc defined.
+ NOTE: this is partially finished td, so more processing to follow that is why its td is not set to
+ null as it is for the case when it is already provided (when td !=null)
*/
- if(td == null) {
- td = new TypeDesc(type);
- /*
- create type descriptor for this class --- NOT its super classes at this point. add super class types.
- */
- Class supa = type.getSuperclass();
- if(supa != null
- && supa != java.lang.Object.class
- && supa != java.lang.Exception.class
- && supa != java.lang.Throwable.class
- && supa != java.rmi.RemoteException.class
- && supa != org.apache.axis.AxisFault.class) {
- configureTypeMapping(desc, supa, defaultNamespace);
- }
-
- /* check to see if a type mapping was created for the super class */
- superTd = TypeDesc.getTypeDescForClass(supa);
- if(superTd != null) {
- /* super class is a regular javabean with axis typedesc */
- superPd = superTd.getPropertyDescriptors();
- }
- td.setXmlType(qname);
- TypeDesc.registerTypeDescForClass(type, td);
- /*
- NOTE: this is partially finished td, so more processing to follow that is why its td is not set to
- null as it is for the case when it is already provided (when td !=null)
- */
- }
- else {
- /*
- we don't need type desc. any more this is a complete td
- */
- td = null;
- }
+ }
+ /* todo: why does this happen here? */
+ else {
/*
- At this all parent bean classes and their properties
- (attributes) have been registered with typedecriptor and
- type mapping. next regidster type for this class.
+ we don't need javaType desc. any more this is a complete td
*/
- tm.register(type,
- qname,
- new EnhancedBeanSerializerFactory(type, qname, td),
- new EnhancedBeanDeserializerFactory(type, qname, td));
+ axisTypeDesc = null;
+ }
+
+ /*
+ Superclass Bean classes and their properties / attributes have been registered with
+ Axis's TypeMapping object. Now, register the javaType.
+ */
+ axisTypeMapping.register(javaType,
+ qname,
+ new EnhancedBeanSerializerFactory(javaType, qname, axisTypeDesc),
+ new EnhancedBeanDeserializerFactory(javaType, qname, axisTypeDesc));
+
+ /*
+ now register the types for this bean properties (attributes)
+ Note: we have to consider the case that one of the properties may be XML bean
+ or a class that can deal with its own serialization.
+ */
+
+ /* Note this is all of the bean properties */
+ Map serProps = BeanDeserializerFactory.getProperties(javaType, null);
+ Iterator iterator = serProps.values().iterator();
+ while(iterator.hasNext()) {
+ BeanPropertyDescriptor beanProps = (BeanPropertyDescriptor)iterator.next();
+ Class subType = beanProps.getType();
/*
- now register the types for this bean properties (attributes)
- Note: we have to consider the case that one of the properties may be XML bean
- or a class that can deal with its own serialization.
+ Make sure the property javaType is configred with Type
+ mapping and its serializer information
*/
+ if(!(subType.isPrimitive() ||
+ subType.getName().startsWith("java.") ||
+ subType.getName().startsWith("javax."))) {
+ configureTypeMapping(axisServiceDesc, subType, targetNamespace);
+ }
- /* Note this is all of the bean properties */
- Map serProps = BeanDeserializerFactory.getProperties(type, null);
- for(BeanPropertyDescriptor beanProps : (Collection<BeanPropertyDescriptor>)serProps.values()) {
- Class subType = beanProps.getType();
- // make sure the property type is configred with Type
- // mapping and its serializer information
- if(!(subType.isPrimitive() ||
- subType.getName().startsWith("java.") ||
- subType.getName().startsWith("javax."))) {
- configureTypeMapping(desc, subType, defaultNamespace);
- // if this was XML bean this recursion would take care of it
- }
+ if(axisTypeDesc != null) {
+ /*
+ if I didn't have javaType descriptor when I came to this method... I
+ created partially filled one above now need to complete this.
+ */
+ String ns = qname.getNamespaceURI();
- if(td != null) {
- /*
- if I didn't have type descriptor when I came to this method... I
- created partially filled one above now need to complete this.
- */
- String ns = qname.getNamespaceURI();
- /*
- name space for the class if there is no parent find proper namespace for this element...
- we need to find out which class in the hierarchy the element came from once you know
- where the element came form (which class) then you know the element's name space.
- */
- if(superTd != null && superPd != null) {
- for(int j = 0; j < superPd.length; j++) {
- if(beanProps.getName().equals(superPd[j].getName())) {
- ns = superTd.getXmlType().getNamespaceURI();
- break;
- }
+ /*
+ name space for the class if there is no parent find proper namespace for this element...
+ we need to find out which class in the hierarchy the element came from once you know
+ where the element came form (which class) then you know the element's name space.
+ */
+ if(superAxisTypeDesc != null && superPd != null) {
+ for(int j = 0; j < superPd.length; j++) {
+ if(beanProps.getName().equals(superPd[j].getName())) {
+ ns = superAxisTypeDesc.getXmlType().getNamespaceURI();
+ break;
}
}
- FieldDesc fd = new ElementDesc();
- fd.setJavaType(subType);
- fd.setFieldName(beanProps.getName());
- fd.setXmlName(new QName(ns, beanProps.getName()));
- // NOTE jcolwell@bea.com 2004-Oct-28 -- might need to do more to ensure a useful type QName.
- fd.setXmlType(tm.getTypeQName(subType));
- ((ElementDesc)fd).setNillable(true);
- // mmerz@apache.com 2005-Mar-09: required since Axis 1.2RC3 to allow for null values in complex
- // objects; note that there is no (JSR-181) annotation that allows configuring this value.
- td.addFieldDesc(fd);
}
+ FieldDesc fd = new ElementDesc();
+ fd.setJavaType(subType);
+ fd.setFieldName(beanProps.getName());
+ fd.setXmlName(new QName(ns, beanProps.getName()));
+
+ // NOTE jcolwell@bea.com 2004-Oct-28 -- might need to do more to ensure a useful javaType QName.
+ fd.setXmlType(axisTypeMapping.getTypeQName(subType));
+ ((ElementDesc)fd).setNillable(true);
+
+ // mmerz@apache.com 2005-Mar-09: required since Axis 1.2RC3 to allow for null values in complex
+ // objects; note that there is no (JSR-181) annotation that allows configuring this value.
+ axisTypeDesc.addFieldDesc(fd);
}
}
- else {
- throw new InvalidTypeMappingException("Unable to register "
- + type.getName()
- + " as a valid web service datatype, consider using a custom type mapping");
- }
}
return qname;
}
- private void configureSoapBinding(ServiceDesc sd, BeehiveWsSOAPBindingInfo sbi) {
- javax.jws.soap.SOAPBinding.Style style = javax.jws.soap.SOAPBinding.Style.DOCUMENT;
- javax.jws.soap.SOAPBinding.Use use = javax.jws.soap.SOAPBinding.Use.LITERAL;
- javax.jws.soap.SOAPBinding.ParameterStyle paramStyle = javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED;
- if(sbi != null) {
- style = sbi.getStyle();
- use = sbi.getUse();
- paramStyle = sbi.getParameterStyle();
- }
- if(style == javax.jws.soap.SOAPBinding.Style.RPC) {
- sd.setStyle(Style.RPC);
- if(use == javax.jws.soap.SOAPBinding.Use.ENCODED) {
- sd.setUse(Use.ENCODED);
- }
- else sd.setUse(Use.LITERAL);
- }
- else {
- /*
- since DOCUMENT ENCODED is not valid so force to use LITERAL
- */
- sd.setUse(Use.LITERAL);
-
- // check if this is a wrapped document literal
- if(paramStyle == javax.jws.soap.SOAPBinding.ParameterStyle.WRAPPED)
- sd.setStyle(Style.WRAPPED);
- /* else regular document style */
- else sd.setStyle(Style.DOCUMENT);
- }
- }
-
private Class createClass(String className) {
if(className == null)
- throw new RuntimeException("Encountered a null class name!");
+ throw new RuntimeException("Can not create class from null class name");
return JavaClassUtils.convertToClass(className);
+ }
+
+ /**
+ * This method will return a boolean value indicating that Activation is
+ * enabled. Activation requires the DataHandler and the Multipart Classes to
+ * both be found.
+ *
+ * @return boolean indicating that Activation is enabled.
+ */
+ private boolean isActivationEnabled() {
+ return null != getDataHandlerClass() && null != getMultipartClass();
+ }
+
+ /**
+ * This will return the Class for the DataHandler. This will return null if
+ * the DataHandler is not available.
+ *
+ * @return The DataHandler Class or null if the DataHandler is not found
+ */
+ private Class getDataHandlerClass() {
+ return loadClass("javax.activation.DataHandler");
+ }
+
+ /**
+ * This will return the Class for the MimeMultipart handler. It will return
+ * null if the MimMultipart class is not available.
+ *
+ * @return The MimeMultipart Class or null if the DataHandler is not found.
+ */
+ private Class getMultipartClass() {
+ return loadClass("javax.mail.internet.MimeMultipart");
+ }
+
+ private static Class loadClass(String className) {
+ try {
+ return ServiceDescriptionFactory.class.getClassLoader().loadClass(className);
+ }
+ catch(ClassNotFoundException e) {
+ LOG.info("Unable to find type \"" + className + "\"");
+ }
+ return null;
}
}
Modified: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/SchemaTypesLookupStrategy.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/SchemaTypesLookupStrategy.java?rev=359257&r1=359256&r2=359257&view=diff
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/SchemaTypesLookupStrategy.java (original)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/SchemaTypesLookupStrategy.java Tue Dec 27 10:21:08 2005
@@ -28,7 +28,7 @@
*
*/
public class SchemaTypesLookupStrategy
- implements BindingLookupStrategy {
+ implements BindingLookupStrategy, TypeMappingConstants {
private static HashMap<Class, QName> SCHEMA_TYPES = new HashMap<Class, QName>();
@@ -50,103 +50,6 @@
return null;
}
- public static final String NS_URI_XML = "http://www.w3.org/XML/1998/namespace";
-
- public static final String URI_1999_SCHEMA_XSD = "http://www.w3.org/1999/XMLSchema";
- public static final String URI_2000_SCHEMA_XSD = "http://www.w3.org/2000/10/XMLSchema";
- public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
- public static final String URI_DEFAULT_SCHEMA_XSD = URI_2001_SCHEMA_XSD;
-
- public static final String URI_SOAP11_ENC = "http://schemas.xmlsoap.org/soap/encoding/";
- public static final String URI_SOAP12_ENC = "http://www.w3.org/2003/05/soap-encoding";
- public static final String URI_DEFAULT_SOAP_ENC = URI_SOAP11_ENC;
-
- public static final String NS_URI_XMLSOAP = "http://xml.apache.org/xml-soap";
-
- public static final QName XSD_STRING = new QName(URI_DEFAULT_SCHEMA_XSD, "string");
- public static final QName XSD_BOOLEAN = new QName(URI_DEFAULT_SCHEMA_XSD, "boolean");
- public static final QName XSD_DOUBLE = new QName(URI_DEFAULT_SCHEMA_XSD, "double");
- public static final QName XSD_FLOAT = new QName(URI_DEFAULT_SCHEMA_XSD, "float");
- public static final QName XSD_INT = new QName(URI_DEFAULT_SCHEMA_XSD, "int");
- public static final QName XSD_INTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "integer");
- public static final QName XSD_LONG = new QName(URI_DEFAULT_SCHEMA_XSD, "long");
- public static final QName XSD_SHORT = new QName(URI_DEFAULT_SCHEMA_XSD, "short");
- public static final QName XSD_BYTE = new QName(URI_DEFAULT_SCHEMA_XSD, "byte");
- public static final QName XSD_DECIMAL = new QName(URI_DEFAULT_SCHEMA_XSD, "decimal");
- public static final QName XSD_BASE64 = new QName(URI_DEFAULT_SCHEMA_XSD, "base64Binary");
- public static final QName XSD_HEXBIN = new QName(URI_DEFAULT_SCHEMA_XSD, "hexBinary");
- public static final QName XSD_ANYSIMPLETYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anySimpleType");
- public static final QName XSD_ANYTYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anyType");
- public static final QName XSD_ANY = new QName(URI_DEFAULT_SCHEMA_XSD, "any");
- public static final QName XSD_QNAME = new QName(URI_DEFAULT_SCHEMA_XSD, "QName");
- public static final QName XSD_DATETIME = new QName(URI_DEFAULT_SCHEMA_XSD, "dateTime");
- public static final QName XSD_DATE = new QName(URI_DEFAULT_SCHEMA_XSD, "date");
- public static final QName XSD_TIME = new QName(URI_DEFAULT_SCHEMA_XSD, "time");
- public static final QName XSD_TIMEINSTANT1999 = new QName(URI_1999_SCHEMA_XSD, "timeInstant");
- public static final QName XSD_TIMEINSTANT2000 = new QName(URI_2000_SCHEMA_XSD, "timeInstant");
-
- public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString");
- public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token");
-
- public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong");
- public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
- public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
- public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
- public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger");
- public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger");
- public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger");
- public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger");
-
- public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
- public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay");
- public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
- public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
- public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
- public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration");
-
- public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name");
- public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName");
- public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN");
- public static final QName XSD_NMTOKENS = new QName(URI_2001_SCHEMA_XSD, "NMTOKENS");
- public static final QName XSD_NOTATION = new QName(URI_2001_SCHEMA_XSD, "NOTATION");
- public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY");
- public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES");
- public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF");
- public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS");
- public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI");
- public static final QName XSD_LANGUAGE = new QName(URI_2001_SCHEMA_XSD, "language");
- public static final QName XSD_ID = new QName(URI_2001_SCHEMA_XSD, "ID");
- public static final QName XSD_SCHEMA = new QName(URI_2001_SCHEMA_XSD, "schema");
-
- public static final QName XML_LANG = new QName(NS_URI_XML, "lang");
-
- public static final QName SOAP_BASE64 = new QName(URI_DEFAULT_SOAP_ENC, "base64");
- public static final QName SOAP_BASE64BINARY = new QName(URI_DEFAULT_SOAP_ENC, "base64Binary");
- public static final QName SOAP_STRING = new QName(URI_DEFAULT_SOAP_ENC, "string");
- public static final QName SOAP_BOOLEAN = new QName(URI_DEFAULT_SOAP_ENC, "boolean");
- public static final QName SOAP_DOUBLE = new QName(URI_DEFAULT_SOAP_ENC, "double");
- public static final QName SOAP_FLOAT = new QName(URI_DEFAULT_SOAP_ENC, "float");
- public static final QName SOAP_INT = new QName(URI_DEFAULT_SOAP_ENC, "int");
- public static final QName SOAP_LONG = new QName(URI_DEFAULT_SOAP_ENC, "long");
- public static final QName SOAP_SHORT = new QName(URI_DEFAULT_SOAP_ENC, "short");
- public static final QName SOAP_BYTE = new QName(URI_DEFAULT_SOAP_ENC, "byte");
- public static final QName SOAP_INTEGER = new QName(URI_DEFAULT_SOAP_ENC, "integer");
- public static final QName SOAP_DECIMAL = new QName(URI_DEFAULT_SOAP_ENC, "decimal");
- public static final QName SOAP_ARRAY = new QName(URI_DEFAULT_SOAP_ENC, "Array");
- public static final QName SOAP_COMMON_ATTRS11 = new QName(URI_SOAP11_ENC, "commonAttributes");
- public static final QName SOAP_COMMON_ATTRS12 = new QName(URI_SOAP12_ENC, "commonAttributes");
- public static final QName SOAP_ARRAY_ATTRS11 = new QName(URI_SOAP11_ENC, "arrayAttributes");
- public static final QName SOAP_ARRAY_ATTRS12 = new QName(URI_SOAP12_ENC, "arrayAttributes");
- public static final QName SOAP_ARRAY12 = new QName(URI_SOAP12_ENC, "Array");
-
- // unsupported since they're bound to Axis
- /*
- private static final QName SOAP_MAP = new QName(NS_URI_XMLSOAP, "Map");
- private static final QName SOAP_ELEMENT = new QName(NS_URI_XMLSOAP, "Element");
- private static final QName SOAP_DOCUMENT = new QName(NS_URI_XMLSOAP, "Document");
- private static final QName SOAP_VECTOR = new QName(NS_URI_XMLSOAP, "Vector");
- */
-
static {
addBuiltInType(XSD_HEXBIN, byte[].class);
addBuiltInType(XSD_BYTE, byte[].class);
@@ -185,74 +88,6 @@
addBuiltInType(XSD_DATETIME, java.util.Calendar.class);
addBuiltInType(SOAP_ARRAY, java.util.ArrayList.class);
-
- /* Axis types */
- /*
- addBuiltInType(XSD_HEXBIN, HexBinary.class);
- // Mapping for xsd:time. Map to Axis type Time
- addBuiltInType(XSD_TIME, org.apache.axis.types.Time.class);
- // These are the g* types (gYearMonth, etc) which map to Axis types
- addBuiltInType(XSD_YEARMONTH, org.apache.axis.types.YearMonth.class);
- addBuiltInType(XSD_YEAR, org.apache.axis.types.Year.class);
- addBuiltInType(XSD_MONTH, org.apache.axis.types.Month.class);
- addBuiltInType(XSD_DAY, org.apache.axis.types.Day.class);
- addBuiltInType(XSD_MONTHDAY, org.apache.axis.types.MonthDay.class);
- */
-
- /* Axis custom types */
- /*
- // Serialize all extensions of Map to SOAP_MAP Order counts here, HashMap should be last.
- addBuiltInType(SOAP_MAP, java.util.Hashtable.class);
- addBuiltInType(SOAP_MAP, java.util.Map.class);
- // The SOAP_MAP will be deserialized into a HashMap by default.
- addBuiltInType(SOAP_MAP, java.util.HashMap.class);
-
- // Use the Element Serializeration for elements
- addBuiltInType(SOAP_ELEMENT, org.w3c.dom.Element.class);
-
- // Use the Document Serializeration for Document's
- addBuiltInType(SOAP_DOCUMENT, org.w3c.dom.Document.class);
-
- addBuiltInType(SOAP_VECTOR, java.util.Vector.class);
- */
- /* attachment support */
- /*
- if (JavaUtils.isAttachmentSupported()) {
- addBuiltInType(MIME_IMAGE, java.awt.Image.class);
- addBuiltInType(MIME_MULTIPART, javax.mail.internet.MimeMultipart.class);
- addBuiltInType(MIME_SOURCE, javax.xml.transform.Source.class);
- addBuiltInType(MIME_OCTETSTREAM, OctetStream.class);
- addBuiltInType(MIME_DATA_HANDLER, javax.activation.DataHandler.class);
- }
- */
-
- /*
- addBuiltInType(XSD_TOKEN, org.apache.axis.types.Token.class);
- addBuiltInType(XSD_NORMALIZEDSTRING, org.apache.axis.types.NormalizedString.class);
- addBuiltInType(XSD_UNSIGNEDLONG, org.apache.axis.types.UnsignedLong.class);
- addBuiltInType(XSD_UNSIGNEDINT, org.apache.axis.types.UnsignedInt.class);
- addBuiltInType(XSD_UNSIGNEDSHORT, org.apache.axis.types.UnsignedShort.class);
- addBuiltInType(XSD_UNSIGNEDBYTE, org.apache.axis.types.UnsignedByte.class);
- addBuiltInType(XSD_NONNEGATIVEINTEGER, org.apache.axis.types.NonNegativeInteger.class);
- addBuiltInType(XSD_NEGATIVEINTEGER, org.apache.axis.types.NegativeInteger.class);
- addBuiltInType(XSD_POSITIVEINTEGER, org.apache.axis.types.PositiveInteger.class);
- addBuiltInType(XSD_NONPOSITIVEINTEGER, org.apache.axis.types.NonPositiveInteger.class);
- addBuiltInType(XSD_NAME, org.apache.axis.types.Name.class);
- addBuiltInType(XSD_NCNAME, org.apache.axis.types.NCName.class);
- addBuiltInType(XSD_ID, org.apache.axis.types.Id.class);
- addBuiltInType(XML_LANG, org.apache.axis.types.Language.class);
- addBuiltInType(XSD_LANGUAGE, org.apache.axis.types.Language.class);
- addBuiltInType(XSD_NMTOKEN, org.apache.axis.types.NMToken.class);
- addBuiltInType(XSD_NMTOKENS, org.apache.axis.types.NMTokens.class);
- addBuiltInType(XSD_NOTATION, org.apache.axis.types.Notation.class);
- addBuiltInType(XSD_ENTITY, org.apache.axis.types.Entity.class);
- addBuiltInType(XSD_ENTITIES, org.apache.axis.types.Entities.class);
- addBuiltInType(XSD_IDREF, org.apache.axis.types.IDRef.class);
- addBuiltInType(XSD_IDREFS, org.apache.axis.types.IDRefs.class);
- addBuiltInType(XSD_DURATION, org.apache.axis.types.Duration.class);
- addBuiltInType(XSD_ANYURI, org.apache.axis.types.URI.class);
- addBuiltInType(XSD_SCHEMA, org.apache.axis.types.Schema.class);
- */
}
private static void addBuiltInType(QName qname, Class clazz) {
Added: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/TypeMappingConstants.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/TypeMappingConstants.java?rev=359257&view=auto
==============================================================================
--- beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/TypeMappingConstants.java (added)
+++ beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/TypeMappingConstants.java Tue Dec 27 10:21:08 2005
@@ -0,0 +1,123 @@
+/**
+ Copyright 2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ $Header:$
+ */
+package org.apache.beehive.wsm.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public interface TypeMappingConstants {
+
+ public static final String NS_URI_XML = "http://www.w3.org/XML/1998/namespace";
+
+ public static final String URI_1999_SCHEMA_XSD = "http://www.w3.org/1999/XMLSchema";
+ public static final String URI_2000_SCHEMA_XSD = "http://www.w3.org/2000/10/XMLSchema";
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+ public static final String URI_DEFAULT_SCHEMA_XSD = URI_2001_SCHEMA_XSD;
+
+ public static final String URI_SOAP11_ENC = "http://schemas.xmlsoap.org/soap/encoding/";
+ public static final String URI_SOAP12_ENC = "http://www.w3.org/2003/05/soap-encoding";
+ public static final String URI_DEFAULT_SOAP_ENC = URI_SOAP11_ENC;
+
+ public static final String NS_URI_XMLSOAP = "http://xml.apache.org/xml-soap";
+
+ public static final QName XSD_STRING = new QName(URI_DEFAULT_SCHEMA_XSD, "string");
+ public static final QName XSD_BOOLEAN = new QName(URI_DEFAULT_SCHEMA_XSD, "boolean");
+ public static final QName XSD_DOUBLE = new QName(URI_DEFAULT_SCHEMA_XSD, "double");
+ public static final QName XSD_FLOAT = new QName(URI_DEFAULT_SCHEMA_XSD, "float");
+ public static final QName XSD_INT = new QName(URI_DEFAULT_SCHEMA_XSD, "int");
+ public static final QName XSD_INTEGER = new QName(URI_DEFAULT_SCHEMA_XSD, "integer");
+ public static final QName XSD_LONG = new QName(URI_DEFAULT_SCHEMA_XSD, "long");
+ public static final QName XSD_SHORT = new QName(URI_DEFAULT_SCHEMA_XSD, "short");
+ public static final QName XSD_BYTE = new QName(URI_DEFAULT_SCHEMA_XSD, "byte");
+ public static final QName XSD_DECIMAL = new QName(URI_DEFAULT_SCHEMA_XSD, "decimal");
+ public static final QName XSD_BASE64 = new QName(URI_DEFAULT_SCHEMA_XSD, "base64Binary");
+ public static final QName XSD_HEXBIN = new QName(URI_DEFAULT_SCHEMA_XSD, "hexBinary");
+ public static final QName XSD_ANYSIMPLETYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anySimpleType");
+ public static final QName XSD_ANYTYPE = new QName(URI_DEFAULT_SCHEMA_XSD, "anyType");
+ public static final QName XSD_ANY = new QName(URI_DEFAULT_SCHEMA_XSD, "any");
+ public static final QName XSD_QNAME = new QName(URI_DEFAULT_SCHEMA_XSD, "QName");
+ public static final QName XSD_DATETIME = new QName(URI_DEFAULT_SCHEMA_XSD, "dateTime");
+ public static final QName XSD_DATE = new QName(URI_DEFAULT_SCHEMA_XSD, "date");
+ public static final QName XSD_TIME = new QName(URI_DEFAULT_SCHEMA_XSD, "time");
+ public static final QName XSD_TIMEINSTANT1999 = new QName(URI_1999_SCHEMA_XSD, "timeInstant");
+ public static final QName XSD_TIMEINSTANT2000 = new QName(URI_2000_SCHEMA_XSD, "timeInstant");
+
+ public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString");
+ public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token");
+
+ public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong");
+ public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
+ public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
+ public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
+ public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger");
+ public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger");
+ public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger");
+ public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger");
+
+ public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
+ public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay");
+ public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
+ public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
+ public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
+ public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration");
+
+ public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name");
+ public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName");
+ public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN");
+ public static final QName XSD_NMTOKENS = new QName(URI_2001_SCHEMA_XSD, "NMTOKENS");
+ public static final QName XSD_NOTATION = new QName(URI_2001_SCHEMA_XSD, "NOTATION");
+ public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY");
+ public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES");
+ public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF");
+ public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS");
+ public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI");
+ public static final QName XSD_LANGUAGE = new QName(URI_2001_SCHEMA_XSD, "language");
+ public static final QName XSD_ID = new QName(URI_2001_SCHEMA_XSD, "ID");
+ public static final QName XSD_SCHEMA = new QName(URI_2001_SCHEMA_XSD, "schema");
+
+ public static final QName XML_LANG = new QName(NS_URI_XML, "lang");
+
+ public static final QName SOAP_BASE64 = new QName(URI_DEFAULT_SOAP_ENC, "base64");
+ public static final QName SOAP_BASE64BINARY = new QName(URI_DEFAULT_SOAP_ENC, "base64Binary");
+ public static final QName SOAP_STRING = new QName(URI_DEFAULT_SOAP_ENC, "string");
+ public static final QName SOAP_BOOLEAN = new QName(URI_DEFAULT_SOAP_ENC, "boolean");
+ public static final QName SOAP_DOUBLE = new QName(URI_DEFAULT_SOAP_ENC, "double");
+ public static final QName SOAP_FLOAT = new QName(URI_DEFAULT_SOAP_ENC, "float");
+ public static final QName SOAP_INT = new QName(URI_DEFAULT_SOAP_ENC, "int");
+ public static final QName SOAP_LONG = new QName(URI_DEFAULT_SOAP_ENC, "long");
+ public static final QName SOAP_SHORT = new QName(URI_DEFAULT_SOAP_ENC, "short");
+ public static final QName SOAP_BYTE = new QName(URI_DEFAULT_SOAP_ENC, "byte");
+ public static final QName SOAP_INTEGER = new QName(URI_DEFAULT_SOAP_ENC, "integer");
+ public static final QName SOAP_DECIMAL = new QName(URI_DEFAULT_SOAP_ENC, "decimal");
+ public static final QName SOAP_ARRAY = new QName(URI_DEFAULT_SOAP_ENC, "Array");
+ public static final QName SOAP_COMMON_ATTRS11 = new QName(URI_SOAP11_ENC, "commonAttributes");
+ public static final QName SOAP_COMMON_ATTRS12 = new QName(URI_SOAP12_ENC, "commonAttributes");
+ public static final QName SOAP_ARRAY_ATTRS11 = new QName(URI_SOAP11_ENC, "arrayAttributes");
+ public static final QName SOAP_ARRAY_ATTRS12 = new QName(URI_SOAP12_ENC, "arrayAttributes");
+ public static final QName SOAP_ARRAY12 = new QName(URI_SOAP12_ENC, "Array");
+
+ // unsupported since they're bound to Axis
+ /*
+ private static final QName SOAP_MAP = new QName(NS_URI_XMLSOAP, "Map");
+ private static final QName SOAP_ELEMENT = new QName(NS_URI_XMLSOAP, "Element");
+ private static final QName SOAP_DOCUMENT = new QName(NS_URI_XMLSOAP, "Document");
+ private static final QName SOAP_VECTOR = new QName(NS_URI_XMLSOAP, "Vector");
+ */
+}
Propchange: beehive/trunk/wsm/src/core/org/apache/beehive/wsm/util/TypeMappingConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeDocWebService.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeDocWebService.java?rev=359257&r1=359256&r2=359257&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeDocWebService.java (original)
+++ beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeDocWebService.java Tue Dec 27 10:21:08 2005
@@ -23,7 +23,7 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
-import org.apache.beehive.wsm.axis.beans.ModeratelyComplexObject;
+import org.apache.beehive.wsm.axis.beans.ComplexJavaBean;
import org.apache.beehive.wsm.axis.exceptions.ComplexUserDefinedException;
import org.apache.beehive.wsm.axis.exceptions.SimpleUserDefinedException;
@@ -41,7 +41,7 @@
@WebMethod(operationName = "processThingy")
@Oneway
- public void processModeratelyComplexObject(@WebParam(name = "thingy") ModeratelyComplexObject mco) {
+ public void processModeratelyComplexObject(@WebParam(name = "thingy") ComplexJavaBean mco) {
}
@WebMethod
Modified: beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeRpcWebService.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeRpcWebService.java?rev=359257&r1=359256&r2=359257&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeRpcWebService.java (original)
+++ beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/FakeRpcWebService.java Tue Dec 27 10:21:08 2005
@@ -17,16 +17,14 @@
*/
package org.apache.beehive.wsm.axis;
-import java.math.BigDecimal;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
-import javax.xml.rpc.holders.Holder;
-import org.apache.beehive.wsm.axis.beans.ModeratelyComplexObject;
+import org.apache.beehive.wsm.axis.beans.ComplexJavaBean;
import org.apache.beehive.wsm.holders.SessionIdHolder;
/**
@@ -45,7 +43,7 @@
@WebMethod(operationName = "processThingy")
@Oneway
- public void processModeratelyComplexObject(@WebParam(name = "thingy") ModeratelyComplexObject mco) {
+ public void processModeratelyComplexObject(@WebParam(name = "thingy") ComplexJavaBean mco) {
}
@WebMethod
Copied: beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ComplexJavaBean.java (from r358086, beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ModeratelyComplexObject.java)
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ComplexJavaBean.java?p2=beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ComplexJavaBean.java&p1=beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ModeratelyComplexObject.java&r1=358086&r2=359257&rev=359257&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ModeratelyComplexObject.java (original)
+++ beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ComplexJavaBean.java Tue Dec 27 10:21:08 2005
@@ -25,7 +25,7 @@
/**
*
*/
-public class ModeratelyComplexObject
+public class ComplexJavaBean
implements Serializable {
private Date _date;
Propchange: beehive/trunk/wsm/test/src/junit-services/org/apache/beehive/wsm/axis/beans/ComplexJavaBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/EndpointInterfaceServiceTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/EndpointInterfaceServiceTest.java?rev=359257&r1=359256&r2=359257&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/EndpointInterfaceServiceTest.java (original)
+++ beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/jsr181/model/EndpointInterfaceServiceTest.java Tue Dec 27 10:21:08 2005
@@ -79,6 +79,11 @@
method.getJavaReturnType());
}
+ /**
+ * This method ensures that the <i>dropMoney</i> method appears in the WSDL.
+ *
+ * @throws Exception
+ */
public void testWebMethodDropMoney()
throws Exception {
BeehiveWsMethodMetadata method = getMethod("dropMoney");
Modified: beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/types/QNameToClassTest.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/types/QNameToClassTest.java?rev=359257&r1=359256&r2=359257&view=diff
==============================================================================
--- beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/types/QNameToClassTest.java (original)
+++ beehive/trunk/wsm/test/src/junit/org/apache/beehive/wsm/test/types/QNameToClassTest.java Tue Dec 27 10:21:08 2005
@@ -28,24 +28,25 @@
public class QNameToClassTest
extends TestCase {
- public void testPrimitive() {
+ public void testPrimitiveLong() {
BindingLookupStrategy bindingLookupStrategy = new SchemaTypesLookupStrategy();
Class clazz = bindingLookupStrategy.qname2class(SchemaTypesLookupStrategy.XSD_LONG);
System.out.println("primitive type mapped to: " + clazz);
- assertTrue(long.class == clazz);
+ assertTrue(long.class == clazz || Long.class == clazz);
}
+/* todo: need to support SOAP encoding */
+/*
+ public void testWrappedLong() {
+ BindingLookupStrategy bindingLookupStrategy = new SchemaTypesLookupStrategy();
+ Class clazz = bindingLookupStrategy.qname2class(SchemaTypesLookupStrategy.SOAP_LONG);
+ System.out.println("wrapped type mapped to: " + clazz);
+ assertTrue(Long.class == clazz);
+ }
+*/
- public void testPrimitive_xmlbeans() {
+ public void testPrimitiveLong_xmlbeans() {
BindingLookupStrategy bindingLookupStrategy = new XmlBeanLookupStrategy();
Class clazz = bindingLookupStrategy.qname2class(SchemaTypesLookupStrategy.XSD_LONG);
assertTrue(long.class == clazz);
}
-
-/*
- public void testWrapped() {
- BindingLookupStrategy bindingLookupService = new SchemaTypesLookupStrategy();
- Class clazz = bindingLookupService.qname2class(SchemaTypesLookupStrategy.XSD_LONG);
- assertTrue(Long.class == clazz);
- }
-*/
}