You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/09/18 01:19:53 UTC

svn commit: rev 46286 - incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis

Author: mmerz
Date: Fri Sep 17 16:19:52 2004
New Revision: 46286

Modified:
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
Log:
Fixed the type mappings when configuring the service.  BeanSerializers will be
used by default and unpackaged classes will use the default namespace of the web 
service rather than "http://DefaultNamespace".

Contributor: Jonathan Colwell



Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
==============================================================================
--- 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	Fri Sep 17 16:19:52 2004
@@ -23,7 +23,11 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis.wsdl.fromJava.Emitter;
-import org.apache.axis.encoding.DefaultSOAPEncodingTypeMappingImpl;
+import org.apache.axis.wsdl.fromJava.Namespaces;
+import org.apache.axis.wsdl.fromJava.Types;
+import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.encoding.ser.BeanDeserializerFactory;
+import org.apache.axis.encoding.ser.BeanSerializerFactory;
 import org.apache.axis.description.ServiceDesc;
 import org.apache.axis.description.JavaServiceDesc;
 import org.apache.axis.description.ParameterDesc;
@@ -92,8 +96,10 @@
                     od.setReturnClass(java.lang.Void.TYPE);
                 }
                 else {
-                    od.setReturnQName(new QName(meth.getWrName()));   
-                    od.setReturnClass(meth.getJavaReturnType());
+                    od.setReturnQName(new QName(meth.getWrName()));
+                    Class returnType = meth.getJavaReturnType();
+                    configureTypeMapping(sd, returnType);
+                    od.setReturnClass(returnType);
                     //od.setReturnHeader(
                 }
             
@@ -105,6 +111,7 @@
                     ParameterDesc pd = new ParameterDesc();
                     pd.setName(param.getWpName());
                     Class paramType = param.getJavaType();
+                    configureTypeMapping(sd, paramType);
                     pd.setJavaType(paramType);
                     paramClasses.add(paramType);
 
@@ -144,6 +151,24 @@
         sd.setAllowedMethods(allowedMethods);
         
         return sd;
+    }
+
+    private static void configureTypeMapping(ServiceDesc desc, Class type) {
+        TypeMapping tm = desc.getTypeMapping();
+        QName q = tm.getTypeQName(type);
+        if (q == null) {
+            String namespace = Namespaces.makeNamespace( type.getName() ) ;
+            if (namespace == null  || namespace.endsWith("DefaultNamespace")) {
+                namespace = desc.getDefaultNamespace();
+            }
+            q = new QName(namespace,                          
+                          Types.getLocalNameFromFullName( type.getName() ) );
+            if (! tm.isRegistered(type, q)) {
+                tm.register( type, q,
+                             new BeanSerializerFactory(type, q),
+                             new BeanDeserializerFactory(type, q));
+            }
+        }
     }
 
     protected static void configureSoapBinding(ServiceDesc sd,