Author: jongjinchoi
Date: Wed Mar 16 05:17:02 2005
New Revision: 157742
URL: http://svn.apache.org/viewcvs?view=rev&rev=157742
Log:
Make the wsm-addressbook-enhanced sample functional in wrapped/literal mode
with .NET.
To work in wrapped/literal mode, we need to fill the appropriate typeQName of
ParameterDesc.
To fill the typeQName, do the following:
1) Instead of creating a new OperationDesc and ParameterDesc,
use the Axis's introspection feature to get them.
The intropsected OperationDesc and ParameterDesc have appropriate TypeEntry,
and this is required for WSM to work in wrapped/literal mode.
2) don't register ArraySer/Deser in literal mode.
The typeQName of ParameterDesc should be the type QName of its component type.
The introspected ones are overrided by WSM.
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java?view=diff&r1=157741&r2=157742
==============================================================================
---
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
(original)
+++
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
Wed Mar 16 05:17:02 2005
@@ -22,6 +22,7 @@
import java.rmi.Remote;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -42,6 +43,10 @@
import org.apache.axis.encoding.DeserializerFactory;
import org.apache.axis.encoding.SerializerFactory;
import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.encoding.TypeMappingDelegate;
+import org.apache.axis.encoding.TypeMappingImpl;
+import org.apache.axis.encoding.TypeMappingRegistry;
+import org.apache.axis.encoding.TypeMappingRegistryImpl;
import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
import org.apache.axis.encoding.ser.ArraySerializerFactory;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
@@ -68,7 +73,6 @@
* @author Jonathan Colwell
*/
public class AxisHook {
-
public static ServiceDesc createServiceDesc(
BeehiveWsTypeMetadata wsm,
ClassLoader cl
@@ -93,14 +97,40 @@
String targetNamespace = wsm.getWsTargetNamespace();
sd.setDefaultNamespace(targetNamespace);
configureSoapBinding(sd, wsm.getSoapBinding());
+
List<String> allowedMethods = new ArrayList<String>();
+
+ for (BeehiveWsMethodMetadata meth : wsm.getMethods())
+ {
+ String method = meth.getJavaMethodName();
+ allowedMethods.add(method);
+ }
+
+
+ sd.setName(wsm.getWsName());
+ sd.setDefaultNamespace(targetNamespace);
+ sd.setAllowedMethods(allowedMethods);
+ configureSoapBinding(sd, wsm.getSoapBinding());
+
+ TypeMappingRegistry tmr = new TypeMappingRegistryImpl(true);
+ TypeMapping tm = tmr.getOrMakeTypeMapping(sd.getUse() == Use.ENCODED ?
"encoded" : "");
+ sd.setTypeMappingRegistry(tmr);
+ sd.setTypeMapping(tm);
+
+ /* [EMAIL PROTECTED] 2005-Mar-16 --
+ * Use Axis's introspection feature instead of creating new
OperationDesc and ParameterDescs directly.
+ * The introspected OperationDesc and ParameterDescs are overrided by
WSM.
+ * When appropriate type mapping registry is set, Axis fills the
ParameterDesc's typeEntry from the preset typemapping registry,
+ * which is required for Axis to work in wrapped/lit mode.
+ */
+ sd.getOperations();
+
for (BeehiveWsMethodMetadata meth : wsm.getMethods())
{
String operationName = meth.getWmOperationName();
if (null != operationName && 0 < operationName.length())
{
- allowedMethods.add(operationName);
- OperationDesc od = new OperationDesc();
+ OperationDesc od =
sd.getOperationByName(meth.getJavaMethodName());
od.setElementQName(new QName(targetNamespace, operationName));
od.setName(operationName);
od.setSoapAction(meth.getWmAction());
@@ -114,23 +144,29 @@
new QName(meth.getWrTargetNamespace(),
meth.getWrName())
);
final Class returnType = meth.getJavaReturnType();
- od.setReturnType(configureTypeMapping(sd, returnType,
meth.getWrTargetNamespace()));
+ QName qn = configureTypeMapping(sd, returnType,
meth.getWrTargetNamespace());
+ od.setReturnType(qn);
od.setReturnClass(returnType);
}
- List<Class> paramClasses = new ArrayList<Class>();
+ int pcnt = 0;
for (BeehiveWsParameterMetadata param : meth.getParams())
{
- ParameterDesc pd = new ParameterDesc();
+ ParameterDesc pd = od.getParameter(pcnt++);
final Class paramType = param.getJavaType();
- paramClasses.add(paramType);
- final QName dummy = configureTypeMapping(sd, paramType,
param.getWpTargetNamespace());
+ if (pd.getTypeQName() == null) { // set the typeQName
if it is not set already.
+ QName typeQName = configureTypeMapping(sd, paramType,
param.getWpTargetNamespace());
+ /* [EMAIL PROTECTED] 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);
+ }
+ QName paramQName = new QName(param.getWpTargetNamespace(),
param.getWpName());
// set QName
- pd.setQName(
- new QName(param.getWpTargetNamespace(),
- param.getWpName())
- );
+ pd.setQName(paramQName);
+
// set Mode
final boolean header = param.isWpHeader();
@@ -156,41 +192,24 @@
}
// set JavaType
- pd.setJavaType(paramType);
-
- od.addParameter(pd);
+ pd.setJavaType(paramType);
}
- Method javaMethod =
- serviceClass.getMethod(
- meth.getJavaMethodName(),
- paramClasses.toArray(new Class[paramClasses.size()])
- );
+ Method javaMethod = od.getMethod();
// set Exceptions
for (Class thrown : javaMethod.getExceptionTypes())
{
- FaultDesc fd = new FaultDesc();
- fd.setClassName(thrown.getName());
+ FaultDesc fd = od.getFaultByClass(thrown);
QName qname = configureTypeMapping(sd, thrown,
meth.getWrTargetNamespace());
fd.setXmlType(qname);
fd.setQName(qname);
- fd.setComplex(true);
-
- ParameterDesc pd = new ParameterDesc(qname,
ParameterDesc.IN,
- fd.getXmlType(), thrown);
- ArrayList params = new ArrayList();
- params.add(pd);
- fd.setParameters(params);
- od.addFault(fd);
+ fd.setComplex(true);
}
- // set Method
- od.setMethod(javaMethod);
-
- sd.addOperationDesc(od);
}
}
+
sd.setAllowedMethods(allowedMethods);
return sd;
}
@@ -244,14 +263,20 @@
}
if (type.isArray())
{
- if (! tm.isRegistered(type, q))
+ /* [EMAIL PROTECTED] 2005-Mar-16 --
+ * don't register array serializer in document(bare or
wrapped)/literal mode.
+ */
+ if (! tm.isRegistered(type, q) && desc.getStyle() == Style.RPC
&& desc.getUse() == Use.ENCODED)
{
tm.register(type,
q,
new ArraySerializerFactory(type, q),
new ArrayDeserializerFactory());
}
- configureTypeMapping(desc, type.getComponentType(),
defaultNameSpace);
+ QName qcomp = configureTypeMapping(desc,
type.getComponentType(), defaultNameSpace);
+ if (desc.getUse() == Use.LITERAL) {
+ q = qcomp;
+ }
}
else if (! tm.isRegistered(type, q))
{