axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r398161 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/template/java/ core/src/org/apache/axis2/description/
Date Sat, 29 Apr 2006 14:37:31 GMT
Author: ajith
Date: Sat Apr 29 07:37:29 2006
New Revision: 398161

URL: http://svn.apache.org/viewcvs?rev=398161&view=rev
Log:
1. Modifying the codegen templates slightly. Sometimes the code failed to pickup certain attribute
values correctly due to the namespace decalrations not properly being fed to converter methods.
This was solved by passing the declared namespace map from the envelope to the fromOM method.
2.Removed the verbose flag from the WSDL4J reader

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl?rev=398161&r1=398160&r2=398161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
Sat Apr 29 07:37:29 2006
@@ -51,12 +51,20 @@
 
         public org.apache.xmlbeans.XmlObject fromOM(
             org.apache.axiom.om.OMElement param,
-            java.lang.Class type){
+            java.lang.Class type,
+            java.util.Map extraNamespaces){
         try{
         <xsl:for-each select="param">
             <xsl:if test="@type!=''">
                 if (<xsl:value-of select="@type"/>.class.equals(type)){
-                return <xsl:value-of select="@type"/>.Factory.parse(param.getXMLStreamReaderWithoutCaching())
;
+                if (extraNamespaces!=null){
+                 return <xsl:value-of select="@type"/>.Factory.parse(
+                       param.getXMLStreamReaderWithoutCaching(),
+                       new org.apache.xmlbeans.XmlOptions().setLoadAdditionalNamespaces(extraNamespaces));
+                }else{
+                 return <xsl:value-of select="@type"/>.Factory.parse(
+                       param.getXMLStreamReaderWithoutCaching());
+                }
                 }
             </xsl:if>
         </xsl:for-each>
@@ -128,7 +136,8 @@
         }
 
         public java.lang.Object fromOM(org.apache.axiom.om.OMElement param,
-        java.lang.Class type){
+        java.lang.Class type,
+         java.util.Map extraNamespaces){
             try{
                 javax.xml.transform.Source source =
                         new javanet.staxutils.StAXSource(param.getXMLStreamReader());
@@ -218,8 +227,10 @@
            }
 
 
-            private  java.lang.Object fromOM(org.apache.axiom.om.OMElement param,
-            java.lang.Class type){
+            private  java.lang.Object fromOM(
+            org.apache.axiom.om.OMElement param,
+            java.lang.Class type,
+            java.util.Map extraNamespaces){
 
                 try {
                        <xsl:for-each select="param">
@@ -301,8 +312,10 @@
             return factory.getDefaultEnvelope();
         }
         
-        private java.lang.Object fromOM(org.apache.axiom.om.OMElement param,
-            java.lang.Class type) {
+        private java.lang.Object fromOM(
+            org.apache.axiom.om.OMElement param,
+            java.lang.Class type,
+            java.util.Map extraNamespaces) {
             try {
                 if (bindingFactory == null) {
                     throw new RuntimeException("Could not find JiBX binding information for
com.sosnoski.seismic.jibxsoap.Query, JiBX binding unusable");
@@ -322,7 +335,10 @@
        <!-- #################################################################################
 -->
        <!-- ############################   none template!!!   ##############################
 -->
        <xsl:template match="databinders[@dbtype='none']">
-           private  org.apache.axiom.om.OMElement fromOM(org.apache.axiom.om.OMElement param,
java.lang.Class type){
+           private  org.apache.axiom.om.OMElement fromOM(
+                 org.apache.axiom.om.OMElement param,
+                 java.lang.Class type,
+                 java.util.Map extraNamespaces){
               return param;
            }
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=398161&r1=398160&r2=398161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
Sat Apr 29 07:37:29 2006
@@ -311,7 +311,10 @@
                 <!-- todo need to change this to cater for unwrapped messages (multiple
parts) -->
                 <xsl:choose>
                     <xsl:when test="$style='document' or $style='rpc'">
-                           java.lang.Object object = fromOM(getElement(_returnEnv,"<xsl:value-of
select="$style"/>"),<xsl:value-of select="$outputtype"/>.class);
+                           java.lang.Object object = fromOM(
+                                        getElement(_returnEnv,"<xsl:value-of select="$style"/>"),
+                                        <xsl:value-of select="$outputtype"/>.class,
+                                         getEnvelopeNamespaces(_returnEnv));
                            _messageContext.getTransportOut().getSender().cleanup(_messageContext);
                            return (<xsl:value-of select="$outputtype"/>)object;
                     </xsl:when>
@@ -335,7 +338,7 @@
                         //message class
                         java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName());
                         java.lang.Class messageClass = java.lang.Class.forName(messageClassName);
-                        java.lang.Object messageObject = fromOM(faultElt,messageClass);
+                        java.lang.Object messageObject = fromOM(faultElt,messageClass,null);
                         java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
                                    new java.lang.Class[]{messageClass});
                         m.invoke(ex,new java.lang.Object[]{messageObject});
@@ -462,7 +465,9 @@
                             org.apache.axis2.client.async.AsyncResult result) {
                         java.lang.Object object = fromOM(getElement(
                                 result.getResponseEnvelope(), "document"),
-                               <xsl:value-of select="$outputtype"/>.class);
+                               <xsl:value-of select="$outputtype"/>.class,
+                               getEnvelopeNamespaces(result.getResponseEnvelope())
+                            );
                         callback.receiveResult<xsl:value-of select="@name"/>((<xsl:value-of
select="$outputtype"/>) object);
                     }
 
@@ -544,8 +549,21 @@
            }
             </xsl:if>
         </xsl:for-each>
-	
-	<xsl:if test="//@policy">
+
+       /**
+        *  A utility method that copies the namepaces from the SOAPEnvelope
+        */
+       private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope env){
+        java.util.Map returnMap = new java.util.HashMap();
+        java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces();
+        while (namespaceIterator.hasNext()) {
+            org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace) namespaceIterator.next();
+            returnMap.put(ns.getPrefix(),ns.getName());
+        }
+       return returnMap;
+    }
+
+    <xsl:if test="//@policy">
 	
 	/** */
 	private java.util.HashMap ns2Modules = new java.util.HashMap();

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl?rev=398161&r1=398160&r2=398161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
Sat Apr 29 07:37:29 2006
@@ -83,7 +83,10 @@
                     <xsl:choose>
                         <xsl:when test="$paramCount &gt; 0">skel.<xsl:value-of
select="@name"/>(
                             <xsl:for-each select="input/param[@location='body']">
-                                <xsl:if test="@type!=''">(<xsl:value-of select="@type"/>)fromOM(msgContext.getEnvelope().getBody().getFirstElement(),
<xsl:value-of select="@type"/>.class)<xsl:if test="position() &gt; 1">,</xsl:if></xsl:if>
+                                <xsl:if test="@type!=''">(<xsl:value-of select="@type"/>)fromOM(
+                                    msgContext.getEnvelope().getBody().getFirstElement(),
+                                    <xsl:value-of select="@type"/>.class,
+                                    getEnvelopeNamespaces(msgContext.getEnvelope()))<xsl:if
test="position() &gt; 1">,</xsl:if></xsl:if>
                             </xsl:for-each>);
                         </xsl:when>
                         <!--No input parameters-->
@@ -129,7 +132,21 @@
          <!-- Call templates recursively-->
         //<xsl:apply-templates/>
 
-        }
+          /**
+          *  A utility method that copies the namepaces from the SOAPEnvelope
+          */
+          private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope
env){
+               java.util.Map returnMap = new java.util.HashMap();
+               java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces();
+               while (namespaceIterator.hasNext()) {
+                   org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace)
namespaceIterator.next();
+                   returnMap.put(ns.getPrefix(),ns.getName());
+               }
+              return returnMap;
+              }
+
+
+        }//end of class
     </xsl:template>
    <!-- end of template for in-out message receiver -->
 
@@ -195,7 +212,11 @@
                     <xsl:choose>
                         <xsl:when test="$paramCount &gt; 0"> skel.<xsl:value-of
select="@name"/>(
                             <xsl:for-each select="input/param[@location='body']">
-                                <xsl:if test="@type!=''">(<xsl:value-of select="@type"/>)fromOM(inMessage.getEnvelope().getBody().getFirstElement(),
<xsl:value-of select="@type"/>.class)<xsl:if test="position() &gt; 1">,</xsl:if></xsl:if>
+                                <xsl:if test="@type!=''">(<xsl:value-of select="@type"/>)fromOM(
+                                    inMessage.getEnvelope().getBody().getFirstElement(),
+                                    <xsl:value-of select="@type"/>.class,
+                                    getEnvelopeNamespaces(inMessage.getEnvelope())
+                                    )<xsl:if test="position() &gt; 1">,</xsl:if></xsl:if>
                             </xsl:for-each>);
                         </xsl:when>
                         <xsl:otherwise>skel.<xsl:value-of select="@name"/>();</xsl:otherwise>
@@ -216,10 +237,28 @@
         throw org.apache.axis2.AxisFault.makeFault(e);
         }
         }
+
+
          <!-- Call templates recursively-->
         //<xsl:apply-templates/>
 
-        }
+
+
+        /**
+          *  A utility method that copies the namepaces from the SOAPEnvelope
+          */
+          private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope
env){
+               java.util.Map returnMap = new java.util.HashMap();
+               java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces();
+               while (namespaceIterator.hasNext()) {
+                   org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace)
namespaceIterator.next();
+                   returnMap.put(ns.getPrefix(),ns.getName());
+               }
+              return returnMap;
+              }
+
+
+        }//end of class
 
     </xsl:template>
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java?rev=398161&r1=398160&r2=398161&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL2AxisServiceBuilder.java
Sat Apr 29 07:37:29 2006
@@ -967,6 +967,7 @@
         } else {
 
             reader.setFeature("javax.wsdl.importDocuments", false);
+            reader.setFeature("javax.wsdl.verbose", false);
             Document doc;
             try {
                 doc = XMLUtils.newDocument(in);



Mime
View raw message