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 am...@apache.org on 2007/10/31 14:36:05 UTC

svn commit: r590668 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen: CodeGenerationEngine.java emitter/AxisServiceBasedMultiLanguageEmitter.java emitter/CEmitter.java

Author: amilas
Date: Wed Oct 31 06:36:04 2007
New Revision: 590668

URL: http://svn.apache.org/viewvc?rev=590668&view=rev
Log:
use binding operation to get the polices. earlier it has assumed that the
binding Qname and the operation Qname should be equal. but this is not 
the case if there are in two different wsdl files.

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=590668&r1=590667&r2=590668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java Wed Oct 31 06:36:04 2007
@@ -292,33 +292,8 @@
 
         WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
         reader.setFeature("javax.wsdl.importDocuments", true);
-
-        Document doc;
-        try {
-            doc = XMLUtils.newDocument(uri);
-
-            // Set the URI of the base document for the Definition.
-            // This identifies the origin of the Definition
-            // Note that this is the URI of the base document, not the imports.
-            Definition def = reader.readWSDL(getBaseURI(uri), doc);
-            def.setDocumentBaseURI(getURI(uri));
-
-            return def;
-
-        } catch (ParserConfigurationException e) {
-            throw new WSDLException(WSDLException.PARSER_ERROR,
-                                    "Parser Configuration Error",
-                                    e);
-        } catch (SAXException e) {
-            throw new WSDLException(WSDLException.PARSER_ERROR,
-                                    "Parser SAX Error",
-                                    e);
-
-        } catch (IOException e) {
-            throw new WSDLException(WSDLException.INVALID_WSDL, "IO Error", e);
-        } catch (URISyntaxException e) {
-            throw new WSDLException(WSDLException.OTHER_ERROR, "URI Syntax Error", e);
-        }
+        return reader.readWSDL(uri);
+        
     }
 
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?rev=590668&r1=590667&r2=590668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Wed Oct 31 06:36:04 2007
@@ -269,13 +269,8 @@
         return property;
     }
     
-    private Policy getBindingPolicyFromMessage(QName qName, String key) {
-
-        AxisBindingOperation axisBindingOperation = null;
-        if (axisBinding != null) {
-            axisBindingOperation = (AxisBindingOperation) axisBinding.getChild(qName);
-        }
-
+    private Policy getBindingPolicyFromMessage(AxisBindingOperation axisBindingOperation,
+                                               String key) {
         AxisBindingMessage axisBindingMessage = null;
         
         if (axisBindingOperation != null) {
@@ -285,7 +280,6 @@
                 try {
                     return axisBindingMessage.getEffectivePolicy();
                 } catch (RuntimeException ex){
-                    System.out.println("ERROR: Ignoring policy - " + ex.getMessage());
                     log.error(ex.getMessage(), ex);
                 }
             }
@@ -848,7 +842,7 @@
 
         //////////////////////////////////////////////////////////
 //        System.out.println(DOM2Writer.nodeToString(rootElement));
-        ////////////////////////////////////////////////////////////
+        ////////////////////////////////////////////////
         return doc;
     }
 
@@ -2104,13 +2098,13 @@
         Element methodElement;
         String serviceName = makeJavaClassName(axisService.getName());
 
-        Iterator operationNames = axisService.getOperationsNameList().iterator();
+        Iterator bindingOperations = this.axisBinding.getChildren();
         boolean opsFound = false;
-        QName operationName;
-        while (operationNames.hasNext()) {
-            operationName = (QName) operationNames.next();
-            AxisOperation axisOperation = axisService.getOperation(operationName);
-
+        AxisBindingOperation axisBindingOperation = null;
+        AxisOperation axisOperation = null;
+        while (bindingOperations.hasNext()) {
+            axisBindingOperation = (AxisBindingOperation) bindingOperations.next();
+            axisOperation = axisBindingOperation.getAxisOperation();
             // populate info holder with mep information. This will used in determining which
             // message receiver to use, etc.,
 
@@ -2122,7 +2116,7 @@
 
             if (mep == null) {
                 opsFound = true;
-                methodElement = generateMethodElement(doc, serviceName, axisOperation);
+                methodElement = generateMethodElement(doc, serviceName, axisBindingOperation);
                 rootElement.appendChild(methodElement);
 
             } else {
@@ -2131,7 +2125,7 @@
                 if (mep.equals(axisOperation.getMessageExchangePattern())) {
                     //at this point we know it's true
                     opsFound = true;
-                    methodElement = generateMethodElement(doc, serviceName, axisOperation);
+                    methodElement = generateMethodElement(doc, serviceName, axisBindingOperation);
                     rootElement.appendChild(methodElement);
                     //////////////////////
                 }
@@ -2147,12 +2141,14 @@
      *
      * @param doc
      * @param endpointName
-     * @param axisOperation
+     * @param bindingOperation
      * @return generated element
      * @throws DOMException
      */
-    protected Element generateMethodElement(Document doc, String endpointName,
-                                          AxisOperation axisOperation) throws DOMException {
+    protected Element generateMethodElement(Document doc,
+                                            String endpointName,
+                                            AxisBindingOperation bindingOperation) throws DOMException {
+        AxisOperation axisOperation = bindingOperation.getAxisOperation();
         Element methodElement;
         List soapHeaderInputParameterList = new ArrayList();
         List soapHeaderOutputParameterList = new ArrayList();
@@ -2231,11 +2227,11 @@
                 }
             }
             methodElement.appendChild(getInputElement(doc,
-                    axisOperation, soapHeaderInputParameterList));
+                    bindingOperation, soapHeaderInputParameterList));
         }
         if (WSDLUtil.isOutputPresentForMEP(messageExchangePattern)) {
             methodElement.appendChild(getOutputElement(doc,
-                    axisOperation,
+                    bindingOperation,
                     soapHeaderOutputParameterList));
         }
         methodElement.appendChild(getFaultElement(doc,
@@ -2651,12 +2647,14 @@
      * Get the input element
      *
      * @param doc
-     * @param operation
+     * @param bindingOperation
      * @param headerParameterQNameList
      * @return DOM element
      */
-    protected Element getInputElement(Document doc, AxisOperation operation,
+    protected Element getInputElement(Document doc,
+                                      AxisBindingOperation bindingOperation,
                                       List headerParameterQNameList) {
+        AxisOperation operation = bindingOperation.getAxisOperation();
         Element inputElt = doc.createElement("input");
         String mep = operation.getMessageExchangePattern();
 
@@ -2688,7 +2686,8 @@
             /*
              * Setting the effective policy of input message
              */
-            Policy policy = getBindingPolicyFromMessage(operation.getName(), WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+            Policy policy = getBindingPolicyFromMessage(bindingOperation,
+                    WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
 
             if (policy != null) {
                 try {
@@ -2725,11 +2724,13 @@
      * Finds the output element.
      *
      * @param doc
-     * @param operation
+     * @param bindingOperation
      * @param headerParameterQNameList
      */
-    protected Element getOutputElement(Document doc, AxisOperation operation,
+    protected Element getOutputElement(Document doc,
+                                       AxisBindingOperation bindingOperation,
                                        List headerParameterQNameList) {
+        AxisOperation operation = bindingOperation.getAxisOperation();
         Element outputElt = doc.createElement("output");
         String mep = operation.getMessageExchangePattern();
 
@@ -2758,7 +2759,8 @@
             /*
              * Setting the effective policy for the output message.
              */
-            Policy policy = getBindingPolicyFromMessage(operation.getName(), WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+            Policy policy = getBindingPolicyFromMessage(bindingOperation,
+                    WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
 
             if (policy != null) {
                 try {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java?rev=590668&r1=590667&r2=590668&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java Wed Oct 31 06:36:04 2007
@@ -21,6 +21,7 @@
 import org.apache.axis2.description.AxisMessage;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.description.AxisBindingOperation;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.util.Utils;
@@ -348,10 +349,15 @@
         Element methodElement;
         String portTypeName = makeCClassName(axisService.getName());
 
-        Iterator operations = axisService.getOperations();
+        Iterator bindingOperations = this.axisBinding.getChildren();
         boolean opsFound = false;
-        while (operations.hasNext()) {
-            AxisOperation axisOperation = (AxisOperation)operations.next();
+        AxisOperation axisOperation = null;
+        AxisBindingOperation axisBindingOperation = null;
+
+        while (bindingOperations.hasNext()) {
+
+            axisBindingOperation = (AxisBindingOperation) bindingOperations.next();
+            axisOperation = axisBindingOperation.getAxisOperation();
 
             // populate info holder with mep information. This will used in determining which
             // message receiver to use, etc.,
@@ -410,9 +416,9 @@
                 }
 
                 methodElement.appendChild(
-                        getInputElement(doc, axisOperation, soapHeaderInputParameterList));
+                        getInputElement(doc, axisBindingOperation, soapHeaderInputParameterList));
                 methodElement.appendChild(
-                        getOutputElement(doc, axisOperation, soapHeaderOutputParameterList));
+                        getOutputElement(doc, axisBindingOperation, soapHeaderOutputParameterList));
                 methodElement.appendChild(getFaultElement(doc, axisOperation));
 
                 rootElement.appendChild(methodElement);
@@ -469,10 +475,10 @@
 
 
                     methodElement.appendChild(getInputElement(doc,
-                                                              axisOperation,
+                                                              axisBindingOperation,
                                                               soapHeaderInputParameterList));
                     methodElement.appendChild(getOutputElement(doc,
-                                                               axisOperation,
+                                                               axisBindingOperation,
                                                                soapHeaderOutputParameterList));
                     methodElement.appendChild(getFaultElement(doc,
                                                               axisOperation));



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org