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/10/22 02:25:36 UTC

svn commit: rev 55288 - in incubator/beehive/trunk/wsm: . external src/runtime/org/apache/beehive/wsm/axis src/runtime/org/apache/beehive/wsm/axis/util/encoding

Author: mmerz
Date: Thu Oct 21 17:25:35 2004
New Revision: 55288

Modified:
   incubator/beehive/trunk/wsm/build.xml
   incubator/beehive/trunk/wsm/external/axis-ant.jar
   incubator/beehive/trunk/wsm/external/axis.jar
   incubator/beehive/trunk/wsm/external/jaxrpc.jar
   incubator/beehive/trunk/wsm/external/saaj.jar
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AxisHook.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/encoding/XmlBeanSerializer.java
Log:
Updating the AXIS jars to RC1.

Schemas for complex XmlBeans should now only show up in the WSDL once rather than
multiple times.

Contributor: Jonathan Colwell



Modified: incubator/beehive/trunk/wsm/build.xml
==============================================================================
--- incubator/beehive/trunk/wsm/build.xml	(original)
+++ incubator/beehive/trunk/wsm/build.xml	Thu Oct 21 17:25:35 2004
@@ -26,10 +26,10 @@
     <property name="classes.dir" value="${build.dir}/classes"/>
     <property name="jars.dir" value="${build.dir}/jars"/>
     <property name="docs.dir" value="${build.dir}/docs"/>
+    <property name="wsm.dist.dir" value="${build.dir}/dist"/>
+    <property name="webapps.dist.dir" value="${wsm.dist.dir}/webapps"/>
     <property name="test.dir" value="test"/>
     <property name="webapps.dir" value="${test.dir}/webapps"/>
-    <property name="dist.dir" value="${build.dir}/dist"/>
-    <property name="webapps.dist.dir" value="${dist.dir}/webapps"/>
     <property name="axis.dir" value="AnnotatedAxis"/>
     <property name="api.dir" value="src/api"/>
     <property name="api.classes" value="${classes.dir}/api"/>
@@ -114,6 +114,7 @@
         <mkdir dir="${runtime.classes}"/>
         <mkdir dir="${jars.dir}"/>
         <mkdir dir="${docs.dir}"/>
+        <mkdir dir="${wsm.dist.dir}"/>
     </target>
     <!-- ==================================================================== -->
     <!-- Compiles the source code of the project. -->
@@ -226,7 +227,7 @@
     <!-- ==================================================================== -->
     <target name="deploy" depends="build_all" if="isJDKOver5">
         <echo message="--------------------------------------------------"/>
-        <echo message="|      WSM deploy starting                 |"/>
+        <echo message="|      WSM deploy starting                       |"/>
         <echo message="--------------------------------------------------"/>
         <mkdir dir="${webapps.dist.dir}"/>
         <copy todir="${webapps.dist.dir}/${axis.dir}">

Modified: incubator/beehive/trunk/wsm/external/axis-ant.jar
==============================================================================
Binary files. No diff available.

Modified: incubator/beehive/trunk/wsm/external/axis.jar
==============================================================================
Binary files. No diff available.

Modified: incubator/beehive/trunk/wsm/external/jaxrpc.jar
==============================================================================
Binary files. No diff available.

Modified: incubator/beehive/trunk/wsm/external/saaj.jar
==============================================================================
Binary files. No diff available.

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	Thu Oct 21 17:25:35 2004
@@ -52,6 +52,7 @@
 import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
 import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
 import org.apache.beehive.wsm.jsr181.model.SOAPBindingInfo;
+import org.apache.xmlbeans.XmlBeans;
 import org.apache.xmlbeans.XmlObject;
 
 /*******************************************************************************
@@ -237,10 +238,10 @@
 
               
                     if (XmlObject.class.isAssignableFrom(type)) {
-              
+                        q = XmlBeans.typeForClass(type).getName();
                         tm.register(type, q,
-                             new XmlBeanSerializerFactory(type, q),
-                             new XmlBeanDeserializerFactory(type, q));
+                                    new XmlBeanSerializerFactory(type, q),
+                                    new XmlBeanDeserializerFactory(type, q));
 
                         /*
                          * FIXME jcolwell@bea.com 2004-Oct-18 -- recursively 

Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/encoding/XmlBeanSerializer.java
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/encoding/XmlBeanSerializer.java	(original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/util/encoding/XmlBeanSerializer.java	Thu Oct 21 17:25:35 2004
@@ -21,6 +21,8 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
 import javax.xml.namespace.QName;
 
 import org.apache.axis.Constants;
@@ -28,6 +30,7 @@
 import org.apache.axis.encoding.Serializer;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.XmlAnyURI;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
 import org.apache.xmlbeans.XmlDocumentProperties;
@@ -39,6 +42,9 @@
 import org.w3.x2001.xmlSchema.SchemaDocument;
 import org.w3.x2001.xmlSchema.TopLevelComplexType;
 import org.w3.x2001.xmlSchema.TopLevelElement;
+import org.xmlsoap.schemas.wsdl.TDefinitions;
+import org.xmlsoap.schemas.wsdl.TTypes;
+import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
 import org.xml.sax.Attributes;
 
 /*******************************************************************************
@@ -48,6 +54,9 @@
  */
 public class XmlBeanSerializer implements Serializer {
 
+
+
+
     /**
      * Serialize an element named name, with the indicated attributes
      * and value.
@@ -104,54 +113,103 @@
         if (XmlObject.class.isAssignableFrom(javaType)) {
             SchemaType docType = XmlBeans.typeForClass(javaType);
 
-            InputStream stream = docType.getTypeSystem()
-                .getSourceAsStream(docType.getSourceName());
-            
-            SchemaDocument schemaDoc = SchemaDocument.Factory.parse(stream);
-            
-            TopLevelComplexType[] schemaTypes = schemaDoc.getSchema()
-                .getComplexTypeArray();
-
-
             /*
              * NOTE jcolwell@bea.com 2004-Oct-18 -- 
              * This is a hack to handle node adoption.
              * I don't like it but I need to avoid a 
              * org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR
+             * NOTE jcolwell@bea.com 2004-Oct-21 -- 
+             * since I already use the Document I'll use it to check 
+             * if a schema for the namspace is already in place.
              */
+            
             Document doc = types.createElement("deleteme")
                 .getOwnerDocument();
             
-            for (TopLevelComplexType top : schemaTypes) {
-                System.out.println("checking if " + javaType.getName()
-                                   .toLowerCase()
-                                   + " endsWith " + top.getName().toLowerCase());
-                if (javaType.getName().toLowerCase()
-                    .endsWith(top.getName().toLowerCase())) {
+            XmlOptions opts = new XmlOptions()
+                .setLoadReplaceDocumentElement(null);
+            Element root = doc.getDocumentElement();
+            
+            
+            InputStream stream = docType.getTypeSystem()
+                .getSourceAsStream(docType.getSourceName());
+            
+            SchemaDocument schemaDoc = SchemaDocument.Factory.parse(stream);
+            /*
+             FIXME jcolwell@bea.com 2004-Oct-21 -- it would be great if
+             the Types.loadInputSchema took an input source instead of a 
+             String so I could directly pass in the input stream instead of 
+             providing the schema elements individually.
+            */
+            DefinitionsDocument defDoc = DefinitionsDocument.Factory
+                .newInstance();
+            
 
-                    return(Element)doc.importNode(top.newDomNode()
-                                                  .getFirstChild(), true);
+            TDefinitions definitions = defDoc.addNewDefinitions();
+            definitions.addNewService();
+            Node defEl = definitions.newDomNode(new XmlOptions()
+                                                .setSaveOuter());
+            Document dDoc = defEl.getOwnerDocument();
+            
+            if (null == dDoc.getDocumentElement()) {
+                dDoc.appendChild(defEl);
+            }
+            Set<String> existingNameSpaces = new HashSet<String>();
+            if (dDoc != null) {
+                types.insertTypesFragment(dDoc);
+                Element e = (Element)dDoc.getFirstChild().getFirstChild()
+                    .getFirstChild();
+                if (e != null) {
+                    String tn = e.getAttribute("targetNamespace");
+                    existingNameSpaces.add(tn);
+
+                    while (null != (e = (Element)e.getNextSibling())) {
+                        tn = e.getAttribute("targetNamespace");
+                        existingNameSpaces.add(tn);
+                    }
                 }
             }
-            TopLevelElement[] elements = schemaDoc.getSchema()
-                .getElementArray();
-            int docLen = "Document".length();
-            for (TopLevelElement element : elements) {
-                String elementName = javaType.getName();
-                int lastDot = elementName.lastIndexOf('.');
-                int len = elementName.length();
-                
-                if ((len - lastDot > docLen)
-                    && elementName.substring(lastDot + 1, len - docLen)
-                    .toLowerCase()
-                    .endsWith(element.getName().toLowerCase())) {
+            else {
+                throw new Exception("null document");
+            }
+            
+            SchemaDocument.Schema schema = schemaDoc.getSchema();
+            String targetNamespace = schema.getTargetNamespace();
+
+
+            if (targetNamespace != null) {
+                System.out.println(existingNameSpaces);
+                if (!existingNameSpaces.contains(targetNamespace)) {
+                    TopLevelComplexType[] schemaTypes = schema
+                        .getComplexTypeArray();
+
+
+            
+                    for (TopLevelComplexType top : schemaTypes) {
+
+                        types.writeSchemaElement(targetNamespace,
+                                                 (Element)doc
+                                                 .importNode(top.newDomNode()
+                                                             .getFirstChild(),
+                                                             true));
+                    }
+                    TopLevelElement[] elements = schemaDoc.getSchema()
+                        .getElementArray();
+
+                    for (TopLevelElement element : elements) {
+
+                        types.writeSchemaElement(targetNamespace,
+                                                 (Element)doc
+                                                 .importNode(element.newDomNode()
+                                                             .getFirstChild(),
+                                                             true));
 
-                    return(Element)doc.importNode(element.newDomNode()
-                                                  .getFirstChild(), true);
+                    }
                 }
+                return null;
             }
             throw new Exception(javaType.getName()
-                                + " was not found in the source schema");
+                                + "did not specify a target namspace");
         }
         else {
             throw new Exception(javaType.getName()