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 aj...@apache.org on 2005/10/13 15:36:02 UTC

svn commit: r320767 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/codegen/extension/ codegen/test-resources/ wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/ wsdl/test/org/apache/wsdl/

Author: ajith
Date: Thu Oct 13 06:35:41 2005
New Revision: 320767

URL: http://svn.apache.org/viewcvs?rev=320767&view=rev
Log:
1. Modified the pump to pump Schema DOM elements (not the javax.wsdl.extension.Schema objects) to the schema stack.
2. Fixed some minor build failures
3. Added a proper binding to the BookQuote.wsdl

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote.wsdl
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
    webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java
    webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java?rev=320767&r1=320766&r2=320767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java Thu Oct 13 06:35:41 2005
@@ -69,23 +69,19 @@
                 String key;
                 while (keys.hasNext()) {
                     key = (String) keys.next();
-                    schemaColl.mapNamespace(key,(String)nsMap.get(key));
+                    //schemaColl.mapNamespace(key,(String)nsMap.get(key));
                 }
                 Schema schema;
 
                 if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
                     schema = (Schema) extensiblityElt;
-                    Map inScopeNS = configuration.getWom().getNamespaces();
-                    for (Iterator it = inScopeNS.keySet().iterator(); it.hasNext();) {
-                        String prefix = (String) it.next();
-                        schemaColl.mapNamespace(prefix,
-                                (String)inScopeNS.get(prefix));
-                    }
-
                     Stack importedSchemaStack = schema.getImportedSchemaStack();
                     //compile these schemas
                     while (!importedSchemaStack.isEmpty()) {
-                        Element el = ((javax.wsdl.extensions.schema.Schema)importedSchemaStack.pop()).getElement();
+                        Element el = (Element)importedSchemaStack.pop();
+                        ////////////////////////////////////////////
+                        System.out.println("el = " + el);
+                        ///////////////////////////////////////////
                         XmlSchema thisSchema = schemaColl.read(el);
                         xmlSchemaTypeVector.add(thisSchema);
                     }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=320767&r1=320766&r2=320767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java Thu Oct 13 06:35:41 2005
@@ -124,8 +124,7 @@
                     schemaFolder.mkdir();
                     //compile these schemas
                     while (!importedSchemaStack.isEmpty()) {
-                        javax.wsdl.extensions.schema.Schema tempSchema = (javax.wsdl.extensions.schema.Schema) importedSchemaStack.pop();
-                        Element element = tempSchema.getElement();
+                        Element element = (Element)importedSchemaStack.pop();
 
                         // we are not using DOM toString method here, as it seems it depends on the
                         // JDK version that is being used.

Modified: webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote.wsdl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote.wsdl?rev=320767&r1=320766&r2=320767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote.wsdl (original)
+++ webservices/axis2/trunk/java/modules/codegen/test-resources/BookQuote.wsdl Thu Oct 13 06:35:41 2005
@@ -6,7 +6,6 @@
     </message>
     <message name="BookQuote_getBookPriceResponse">
         <part name="result" type="xsd:anyType"/>
-
     </message>
     <message name="InvalidIsbnFault">
         <part name="message" type="xsd:anyType"/>
@@ -22,15 +21,30 @@
             <output message="mh:BookQuote_getBookPriceResponse"/>
         </operation>
     </portType>
+
     <binding name="BookQuoteBinding" type="mh:BookQuote">
         <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
         <operation name="getBookPrice">
-            <soap:operation/>
+            <soap:operation soapAction="myAction"/>
             <input>
                 <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
             </input>
+            <output>
+                <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
+            </output>
+        </operation>
+
+        <operation name="getBookPriceNonRobust">
+            <soap:operation soapAction="myAction2"/>
+            <input>
+                <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
+            </input>
+            <output>
+                <soap:body use="literal" namespace="http://www.Monson-Haefel.com/jwsbook/BookQuote/BookQuote"/>
+            </output>
         </operation>
     </binding>
+
     <service name="BookQuoteService">
         <port name="BookQuotePort" binding="mh:BookQuoteBinding">
             <soap:address location="http://www.Monson-Haefel.com/jwsbook/BookQuoteService"/>

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java?rev=320767&r1=320766&r2=320767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java Thu Oct 13 06:35:41 2005
@@ -129,6 +129,7 @@
                 wsdlComponentFactory);
         pump.pump();
 
+        //put the debugging serializer code here!
 
         return new WSDLVersionWrapper(wsdlDescription, wsdl1Definition);
 

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java?rev=320767&r1=320766&r2=320767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java Thu Oct 13 06:35:41 2005
@@ -115,7 +115,6 @@
         this.copyExtensibleElements(
                 wsdl4JDefinition.getExtensibilityElements(), wsdlDefinition, null);
 
-        //we need to populate some flags here. Firstly soap stlye
 
 
         /////////////////////////////////////////////////////////////////////
@@ -186,7 +185,9 @@
         while (portTypeIterator.hasNext()) {
             wsdlInterface = this.wsdlComponentFactory.createInterface();
             portType = (PortType) portTypeIterator.next();
-            this.populateInterfaces(wsdlInterface, portType);
+            //////////////////////////
+            this.populateInterfaces(wsdlInterface, portType,wsdl4JDefinition);
+            /////////////////////////
             this.copyExtensibilityAttribute(portType.getExtensionAttributes(),
                     wsdlInterface);
             wsdlDefinition.addInterface(wsdlInterface);
@@ -240,10 +241,10 @@
      * @param wsdlInterface
      * @param wsdl4jPortType
      */
-    //FIXME Evaluate a way of injecting features and priperties with a general
+    // FIXME Evaluate a way of injecting features and priperties with a general
     // formatted input
     private void populateInterfaces(WSDLInterface wsdlInterface,
-                                    PortType wsdl4jPortType) {
+                                    PortType wsdl4jPortType,Definition wsdl4jDefinition) {
 
         //Copy the Attribute information items
         //Copied with the Same QName so it will require no Query in Binding
@@ -253,19 +254,58 @@
                 wsdl4jPortType.getOperations().iterator();
         WSDLOperation wsdloperation;
         Operation wsdl4jOperation;
+
         while (wsdl4JOperationsIterator.hasNext()) {
             wsdloperation = this.wsdlComponentFactory.createOperation();
             wsdl4jOperation = (Operation) wsdl4JOperationsIterator.next();
+            //find whether is's wrappable or not!
+            boolean wrappable = findWrapppable(wsdl4jDefinition,wsdl4jPortType);
+
             this.populateOperations(wsdloperation,
                     wsdl4jOperation,
-                    wsdl4jPortType.getQName().getNamespaceURI());
+                    wsdl4jPortType.getQName().getNamespaceURI(),
+                    wrappable);
+
             this.copyExtensibleElements(
                     wsdl4jOperation.getExtensibilityElements(), wsdloperation, null);
+
             wsdlInterface.setOperation(wsdloperation);
         }
     }
 
     /**
+     *
+     * @param wsdl4jDefinition
+     * @param wsdl4jPortType
+     * @return
+     */
+    private boolean findWrapppable(Definition wsdl4jDefinition,PortType wsdl4jPortType) {
+        //find the binding for this porttype
+        Map bindings = wsdl4jDefinition.getBindings();
+        Iterator bindingIterator= bindings.values().iterator();
+        Binding b ;
+        boolean rpcStatus = false;
+        while (bindingIterator.hasNext()) {
+            b = (Binding) bindingIterator.next();
+            if (b.getPortType().equals(wsdl4jPortType)){
+                //We found a binding that belongs to a particular porttype.
+                //However it is possible to have multiple bindings per PT!
+                //the ideal thing to do here is to go through each and every one and find
+                //if at least one is having rpc style
+                List extElements = b.getExtensibilityElements();
+                for (int i = 0; i < extElements.size(); i++) {
+                    Object o =  extElements.get(i);
+                    if(o instanceof SOAPBinding){
+                        rpcStatus = rpcStatus || ((SOAPBinding)o).getStyle().equals("rpc");
+                    }
+                }
+            }
+
+        }
+        return rpcStatus;
+    }
+
+    /**
      * Pre Condition: The Interface Components must be copied by now.
      */
     private void populateBindings(WSDLBinding wsdlBinding,
@@ -329,7 +369,7 @@
         if (originalSchema==null){
             return;
         }
-        stack.push(originalSchema);
+        stack.push(originalSchema.getElement());
         Map map = originalSchema.getImports();
         Collection values;
         if (map!=null && map.size()>0){
@@ -349,7 +389,8 @@
     //////////////////////////// Internal Component Copying ///////////////////
     public void populateOperations(WSDLOperation wsdlOperation,
                                    Operation wsdl4jOperation,
-                                   String nameSpaceOfTheOperation) {
+                                   String nameSpaceOfTheOperation,
+                                   boolean wrappable) {
         //Copy Name Attrebute
         wsdlOperation.setName(new QName(nameSpaceOfTheOperation,
                 wsdl4jOperation.getName()));
@@ -370,7 +411,7 @@
             Message message = wsdl4jInputMessage.getMessage();
             if (null != message) {
                 wsdlInputMessage.setElement(
-                        this.generateReferenceQname(message));
+                        this.generateReferenceQname(message,wrappable));
                 this.copyExtensibleElements(
                         (message).getExtensibilityElements(),
                         wsdlInputMessage, null);
@@ -394,7 +435,7 @@
             Message outputMessage = wsdl4jOutputMessage.getMessage();
             if (null != outputMessage) {
                 wsdlOutputMessage.setElement(
-                        this.generateReferenceQname(outputMessage));
+                        this.generateReferenceQname(outputMessage,wrappable));
                 this.copyExtensibleElements(
                         (outputMessage).getExtensibilityElements(),
                         wsdlOutputMessage, null);
@@ -418,7 +459,7 @@
             Message faultMessage = fault.getMessage();
             if (null != faultMessage) {
                 faultReference.setRef(
-                        this.generateReferenceQname(faultMessage));
+                        this.generateReferenceQname(faultMessage,wrappable));
             }
             wsdlOperation.addOutFault(faultReference);
             this.copyExtensibilityAttribute(fault.getExtensionAttributes(),
@@ -438,10 +479,10 @@
      * @param wsdl4jMessage
      * @return
      */
-    private QName generateReferenceQname(Message wsdl4jMessage) {
+    private QName generateReferenceQname(Message wsdl4jMessage,boolean isWrappable) {
         QName referenceQName = null;
         //do the wrapping if required
-        if (wrap) {
+        if (isWrappable) {
             Map parts = wsdl4jMessage.getParts();
 
             //            Iterator partsItertator = parts.keySet().iterator();
@@ -508,10 +549,15 @@
                 schemaElement = newDoc.createElementNS(XMLSCHEMA_NAMESPACE_URI, XSD_SCHEMA_QUALIFIED_NAME);
                 schemaExtensibilityElement.setElement(schemaElement);
 
+                //add this to the imported stack as well
+                Stack stack = new Stack();
+                stack.push(schemaElement);
+                schemaExtensibilityElement.setImportedSchemaStack(stack);
+
                 //add the namespace declarations
                 String targetNamespaceUri = wsdl4jMessage.getQName().getNamespaceURI();
                 if (targetNamespaceUri.trim().equals("")){
-                   targetNamespaceUri = getTemporaryNamespaceUri();
+                    targetNamespaceUri = getTemporaryNamespaceUri();
                 }
 
                 schemaElement.setAttribute(XMLNS_AXIS2WRAPPED,
@@ -613,6 +659,13 @@
         return referenceQName;
     }
 
+    /**
+     *
+     * @param wsdlBindingOperation
+     * @param wsdl4jBindingOperation
+     * @param nameSpaceOfTheBindingOperation
+     * @param wsdl4jDefinition
+     */
     private void populateBindingOperation(
             WSDLBindingOperation wsdlBindingOperation,
             BindingOperation wsdl4jBindingOperation,

Modified: webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java?rev=320767&r1=320766&r2=320767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/CreateSchemaTest.java Thu Oct 13 06:35:41 2005
@@ -67,8 +67,9 @@
         Element insertedElementForMessageReference = null;
         for (int i = 0; i < childNodes.getLength(); i++) {
             Node item = childNodes.item(i);
+
             if (item instanceof Element
-                    && "complexType".equals(((Element) item).getTagName())
+                    && "complexType".equals(item.getLocalName())
                     && "BookQuote_getBookPrice".equals(((Element) item)
                     .getAttribute("name"))) {
                 insertedElementForMessageReference = (Element) item;

Modified: webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java?rev=320767&r1=320766&r2=320767&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/test/org/apache/wsdl/MessageReuseTest.java Thu Oct 13 06:35:41 2005
@@ -45,7 +45,7 @@
             String path = getTestResourceFile("BookQuote.wsdl").getAbsolutePath();
             wsdlVersionWrapper =
                     WOMBuilderFactory.getBuilder(org.apache.axis2.wsdl.WSDLConstants.WSDL_1_1)
-                    .build(path);
+                            .build(path);
             this.womDescription = wsdlVersionWrapper.getDescription();
         }
         if (null == wsdl4jDefinition) {
@@ -70,26 +70,30 @@
         Iterator iterator = womDescription.getTypes().getExtensibilityElements()
                 .iterator();
         Schema types = null;
+
+
+        int numberOfBookQuote_getBookPrice = 0;
         while (iterator.hasNext()) {
             WSDLExtensibilityElement temp = (WSDLExtensibilityElement) iterator.next();
             if (ExtensionConstants.SCHEMA.equals(temp.getType())) {
                 types = (Schema) temp;
-            }
-        }
-        int numberOfBookQuote_getBookPrice = 0;
-        NodeList childNodes = types.getElement().getChildNodes();
-        for (int i = 0; i < childNodes.getLength(); i++) {
-            Node item = childNodes.item(i);
-            if (item instanceof Element) {
-                Element temp = (Element) item;
-                if ("complexType".equals(temp.getNodeName()) &&
-                        "BookQuote_getBookPrice".equals(
-                                temp.getAttribute("name"))) {
-                    numberOfBookQuote_getBookPrice++;
-                }
+                NodeList childNodes = types.getElement().getChildNodes();
+                for (int i = 0; i < childNodes.getLength(); i++) {
+                    Node item = childNodes.item(i);
+                    if (item instanceof Element) {
+                        Element tempElt = (Element) item;
+                        if ("complexType".equals(tempElt.getLocalName()) &&
+                                "BookQuote_getBookPrice".equals(
+                                        tempElt.getAttribute("name"))) {
+                            numberOfBookQuote_getBookPrice++;
+                        }
 
+                    }
+                }
             }
         }
+
+
         assertEquals(numberOfBookQuote_getBookPrice, 1);