You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2012/07/02 21:34:17 UTC

svn commit: r1356429 - in /axis/axis2/java/core/trunk/modules: adb-codegen/src/org/apache/axis2/schema/template/ codegen/src/org/apache/axis2/wsdl/template/java/ jaxbri/ jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/ jaxbri/src/test/java/o...

Author: veithen
Date: Mon Jul  2 19:34:15 2012
New Revision: 1356429

URL: http://svn.apache.org/viewvc?rev=1356429&view=rev
Log:
Fix for AXIS2-4197.

The JAXBRI databinding has the following particularity: for a root element declaration that refers to a named complex type, JAXB will only generate a class for the type, but not for the element declaration. JAXB represents an instance of that element by a JAXBElement<T> object, where T is the Java type corresponding to the complex type in the schema (but the corresponding methods in the stub and skeleton will use T). However, it is possible that the schema has multiple root element declarations referring to the same complex type. In that case, it is not possible to determine the element name based on the Java type (because only a single class is generated). This is problematic because there is only a single toEnvelope method per argument type. To solve this, we add a parameter to the toEnvelope method that specifies the element QName. The codegen templates are changed to construct that QName.

Note that this fix looks similar to the original change (r1052896) for that issue, but that change incorrectly used the method (operation) QName, instead of the element QName, causing regressions for a large class of WSDLs (see e.g. AXIS2-5147 and AXIS2-5249).

Added:
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityLinkingServiceImpl.java   (with props)
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityServiceTest.java   (with props)
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identity.xsd
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identityService.wsdl
Modified:
    axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl
    axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
    axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl
    axis/axis2/java/core/trunk/modules/jaxbri/pom.xml
    axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
    axis/axis2/java/core/trunk/modules/jibx/src/main/resources/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
    axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl

Modified: axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl Mon Jul  2 19:34:15 2012
@@ -135,7 +135,7 @@
                                 </xsl:when>
                                 <xsl:otherwise>
                                     <!-- Assumption - the parameter is always an ADB element-->
-                                        private  org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="$inputElementType"/> param, boolean optimizeContent)
+                                        private  org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="$inputElementType"/> param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                                         throws org.apache.axis2.AxisFault{
 
                                              <xsl:choose>
@@ -253,7 +253,7 @@
                   <xsl:variable name="outElementType" select="../../param[@type!='' and @direction='out' and @opname=$opname]/@type"></xsl:variable>
                     <!-- Assumption - The ADBBean here is always an element based bean -->
                     <xsl:if test="generate-id($outElement) = generate-id(key('paramsOut', $outElementType)[1])">
-                    private  org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="../../param[@type!='' and @direction='out' and @opname=$opname]/@type"/> param, boolean optimizeContent)
+                    private  org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="../../param[@type!='' and @direction='out' and @opname=$opname]/@type"/> param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                         throws org.apache.axis2.AxisFault{
                       try{
                           org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope();

Modified: axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Mon Jul  2 19:34:15 2012
@@ -348,22 +348,19 @@
                                                 wrapped parameters -->
                                             <!-- unwrapping takes place only if the back word compatiblity is off. if -b on
                                              then we do not unwrapp and only remove the top element -->
-                                           <xsl:variable name="inputElementType" select="input/param[@location='body' and @type!='']/@type"></xsl:variable>
-                                           <xsl:variable name="inputElementComplexType" select="input/param[@location='body' and @type!='']/@complextype"></xsl:variable>
-                                           <xsl:variable name="opName" select="input/param[@location='body' and @type!='']/@opname"></xsl:variable>
-
+                                            <xsl:variable name="param" select="input/param[@location='body' and @type!='']"/>
                                             <xsl:choose>
-                                                <xsl:when test="(($isbackcompatible='true') and (string-length(normalize-space($inputElementComplexType)) > 0))">
+                                                <xsl:when test="(($isbackcompatible='true') and (string-length(normalize-space($param/@complextype)) > 0))">
                                                      <!-- there are no unwrapped parameters - go ahead and use the normal wrapped codegen-->
                                                     env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
-                                                    wrap<xsl:value-of select="$opName"/>(<xsl:value-of select="input/param[@location='body' and @type!='']/@name"/>),
+                                                    wrap<xsl:value-of select="$param/@opname"/>(<xsl:value-of select="$param/@name"/>),
                                                     optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
                                                     "<xsl:value-of select="$method-name"/>")));
                                                 </xsl:when>
                                                 <xsl:when test="($isUnwrapParameters) and not($isbackcompatible='true')">
-                                                    <xsl:value-of select="$inputElementType"/><xsl:text> </xsl:text>dummyWrappedType = null;
+                                                    <xsl:value-of select="$param/@type"/><xsl:text> </xsl:text>dummyWrappedType = null;
                                                     env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
-                                                    <xsl:for-each select="input/param[@location='body' and @type!='']/param">
+                                                    <xsl:for-each select="$param/param">
                                                         <xsl:value-of select="@name"/>,
                                                     </xsl:for-each>dummyWrappedType,
                                                     optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
@@ -372,9 +369,12 @@
                                                 <xsl:otherwise>
                                                     <!-- there are no unwrapped parameters - go ahead and use the normal wrapped codegen-->
                                                     env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
-                                                    <xsl:value-of select="input/param[@location='body' and @type!='']/@name"/>,
-                                                    optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
-                                                    "<xsl:value-of select="$method-name"/>")));
+                                                    <xsl:value-of select="$param/@name"/>,
+                                                    optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>", "<xsl:value-of select="$method-name"/>")),
+                                                    <xsl:choose>
+                                                        <xsl:when test="$param/qname">new javax.xml.namespace.QName("<xsl:value-of select="$param/qname/@nsuri"/>", "<xsl:value-of select="$param/qname/@localname"/>")</xsl:when>
+                                                        <xsl:otherwise>null</xsl:otherwise>
+                                                    </xsl:choose>);
                                                 </xsl:otherwise>
                                             </xsl:choose>
                                         </xsl:when>
@@ -637,13 +637,13 @@
                                         <xsl:when test="$inputcount=1">
                                             <!-- Even when the parameters are 1 we have to see whether we have the
                                                 wrapped parameters -->
-                                            <xsl:variable name="inputElementType" select="input/param[@location='body' and @type!='']/@type"></xsl:variable>
+                                            <xsl:variable name="param" select="input/param[@location='body' and @type!='']"></xsl:variable>
 
                                             <xsl:choose>
                                                 <xsl:when test="$isUnwrapParameters">
-                                                    <xsl:value-of select="$inputElementType"/><xsl:text> </xsl:text>dummyWrappedType = null;
+                                                    <xsl:value-of select="$param/@type"/><xsl:text> </xsl:text>dummyWrappedType = null;
                                                     env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
-                                                    <xsl:for-each select="input/param[@location='body' and @type!='']/param">
+                                                    <xsl:for-each select="$param/param">
                                                         <xsl:value-of select="@name"/>,
                                                     </xsl:for-each> dummyWrappedType,
                                                     optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
@@ -652,9 +652,12 @@
                                                 <xsl:otherwise>
                                                     <!-- there are no unwrapped parameters - go ahead and use the normal wrapped codegen-->
                                                     env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
-                                                    <xsl:value-of select="input/param[@location='body' and @type!='']/@name"/>,
-                                                    optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
-                                                    "<xsl:value-of select="$method-name"/>")));
+                                                    <xsl:value-of select="$param/@name"/>,
+                                                    optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>", "<xsl:value-of select="$method-name"/>")),
+                                                    <xsl:choose>
+                                                        <xsl:when test="$param/qname">new javax.xml.namespace.QName("<xsl:value-of select="$param/qname/@nsuri"/>", "<xsl:value-of select="$param/qname/@localname"/>")</xsl:when>
+                                                        <xsl:otherwise>null</xsl:otherwise>
+                                                    </xsl:choose>);
                                                 </xsl:otherwise>
                                             </xsl:choose>
                                         </xsl:when>
@@ -950,13 +953,13 @@
                                                         <xsl:when test="$inputcount=1">
                                                             <!-- Even when the parameters are 1 we have to see whether we have the
                                                                 wrapped parameters -->
-                                                            <xsl:variable name="inputElementType" select="input/param[@location='body' and @type!='']/@type"></xsl:variable>
+                                                            <xsl:variable name="param" select="input/param[@location='body' and @type!='']"></xsl:variable>
 
                                                             <xsl:choose>
                                                                 <xsl:when test="$isUnwrapParameters">
-                                                                    <xsl:value-of select="$inputElementType"/><xsl:text> </xsl:text>dummyWrappedType = null;
+                                                                    <xsl:value-of select="$param/@type"/><xsl:text> </xsl:text>dummyWrappedType = null;
                                                                     env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
-                                                                    <xsl:for-each select="input/param[@location='body' and @type!='']/param">
+                                                                    <xsl:for-each select="$param/param">
                                                                         <xsl:value-of select="@name"/>,
                                                                     </xsl:for-each>dummyWrappedType,
                                                                     optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
@@ -965,9 +968,12 @@
                                                                 <xsl:otherwise>
                                                                     <!-- there are no unwrapped parameters - go ahead and use the normal wrapped codegen-->
                                                                     env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
-                                                                    <xsl:value-of select="input/param[@location='body' and @type!='']/@name"/>,
-                                                                    optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>",
-                                                                    "<xsl:value-of select="$method-name"/>")));
+                                                                    <xsl:value-of select="$param/@name"/>,
+                                                                    optimizeContent(new javax.xml.namespace.QName("<xsl:value-of select="$method-ns"/>", "<xsl:value-of select="$method-name"/>")),
+                                                                    <xsl:choose>
+                                                                        <xsl:when test="$param/qname">new javax.xml.namespace.QName("<xsl:value-of select="$param/qname/@nsuri"/>", "<xsl:value-of select="$param/qname/@localname"/>")</xsl:when>
+                                                                        <xsl:otherwise>null</xsl:otherwise>
+                                                                    </xsl:choose>);
                                                                 </xsl:otherwise>
                                                             </xsl:choose>
                                                         </xsl:when>

Modified: axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl Mon Jul  2 19:34:15 2012
@@ -84,12 +84,13 @@
                         <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
                         <xsl:variable name="style"><xsl:value-of select="@style"/></xsl:variable>
 
-                        <xsl:variable name="returntype" select="output/param[@location='body']/@type"/>
-                        <xsl:variable name="returnvariable" select="output/param[@location='body']/@name"/>
-                        <xsl:variable name="returncomplextype"><xsl:value-of select="output/param[@location='body']/@complextype"/></xsl:variable>
-                        <xsl:variable name="returnparamcount"><xsl:value-of select="count(output/param[@location='body']/param)"/></xsl:variable>
-                        <xsl:variable name="returnshorttype"><xsl:value-of select="output/param[@location='body']/@shorttype"/></xsl:variable>
-                        <xsl:variable name="returnpartname"><xsl:value-of select="output/param[@location='body']/param/@partname"/></xsl:variable>
+                        <xsl:variable name="return" select="output/param[@location='body']"/>
+                        <xsl:variable name="returntype" select="$return/@type"/>
+                        <xsl:variable name="returnvariable" select="$return/@name"/>
+                        <xsl:variable name="returncomplextype"><xsl:value-of select="$return/@complextype"/></xsl:variable>
+                        <xsl:variable name="returnparamcount"><xsl:value-of select="count($return/param)"/></xsl:variable>
+                        <xsl:variable name="returnshorttype"><xsl:value-of select="$return/@shorttype"/></xsl:variable>
+                        <xsl:variable name="returnpartname"><xsl:value-of select="$return/param/@partname"/></xsl:variable>
 
 						<xsl:choose>
 	                        <xsl:when test="$returntype = 'byte' or $returntype = 'short' or $returntype = 'int' or $returntype = 'long' or $returntype = 'float' or $returntype = 'double'">
@@ -243,7 +244,11 @@
 
                                 <xsl:choose>
                                     <xsl:when test="string-length(normalize-space($returntype)) &gt; 0">
-                                        envelope = toEnvelope(getSOAPFactory(msgContext), <xsl:value-of select="$returnvariable"/>, false);
+                                        envelope = toEnvelope(getSOAPFactory(msgContext), <xsl:value-of select="$returnvariable"/>, false,
+                                                    <xsl:choose>
+                                                        <xsl:when test="$return/qname">new javax.xml.namespace.QName("<xsl:value-of select="$return/qname/@nsuri"/>", "<xsl:value-of select="$return/qname/@localname"/>")</xsl:when>
+                                                        <xsl:otherwise>null</xsl:otherwise>
+                                                    </xsl:choose>);
                                     </xsl:when>
                                     <xsl:otherwise>
                                         envelope = getSOAPFactory(msgContext).getDefaultEnvelope();

Modified: axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl Mon Jul  2 19:34:15 2012
@@ -34,7 +34,7 @@
         return param;
         }
 
-        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, org.apache.axiom.om.OMElement param, boolean optimizeContent)
+        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, org.apache.axiom.om.OMElement param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
         throws org.apache.axis2.AxisFault {
         org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
         envelope.getBody().addChild(param);

Modified: axis/axis2/java/core/trunk/modules/jaxbri/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/pom.xml?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/jaxbri/pom.xml Mon Jul  2 19:34:15 2012
@@ -142,19 +142,23 @@
                             <tasks unless="maven.test.skip">
                                 <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
                                     <classpath refid="maven.test.classpath" />
-                                    <arg line="-d jaxbri -ss -ssi -sd -t -o ${project.build.directory}/gen/Test01 -u -uri src/test/wsdl/Test01.wsdl" />
+                                    <arg line="-d jaxbri -ss -ssi -sd -o ${project.build.directory}/gen/Test01 -u -uri src/test/wsdl/Test01.wsdl" />
                                 </java>
                                 <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
                                     <classpath refid="maven.test.classpath" />
-                                    <arg line="-d jaxbri -t -o ${project.build.directory}/gen/Test01 -u -uri src/test/wsdl/Test01.wsdl" />
+                                    <arg line="-d jaxbri -o ${project.build.directory}/gen/Test01 -u -uri src/test/wsdl/Test01.wsdl" />
                                 </java>
                                 <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
                                     <classpath refid="maven.test.classpath" />
-                                    <arg line="-d jaxbri -ss -ssi -sd -t -o ${project.build.directory}/gen/processor -u -uri src/test/wsdl/processor.wsdl -ns2p http://www.example.org/data=org.apache.axis2.jaxbri.processor.data,http://www.example.org/ws=org.apache.axis2.jaxbri.processor.service" />
+                                    <arg line="-d jaxbri -ss -ssi -sd -o ${project.build.directory}/gen/processor -u -uri src/test/wsdl/processor.wsdl -ns2p http://www.example.org/data=org.apache.axis2.jaxbri.processor.data,http://www.example.org/ws=org.apache.axis2.jaxbri.processor.service" />
                                 </java>
                                 <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
                                     <classpath refid="maven.test.classpath" />
-                                    <arg line="-d jaxbri -t -o ${project.build.directory}/gen/processor -u -uri src/test/wsdl/processor.wsdl -ns2p http://www.example.org/data=org.apache.axis2.jaxbri.processor.data,http://www.example.org/ws=org.apache.axis2.jaxbri.processor.client" />
+                                    <arg line="-d jaxbri -o ${project.build.directory}/gen/processor -u -uri src/test/wsdl/processor.wsdl -ns2p http://www.example.org/data=org.apache.axis2.jaxbri.processor.data,http://www.example.org/ws=org.apache.axis2.jaxbri.processor.client" />
+                                </java>
+                                <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
+                                    <classpath refid="maven.test.classpath" />
+                                    <arg line="-d jaxbri -ss -ssi -sd -g -o ${project.build.directory}/gen/identityservice -u -uri src/test/wsdl/identityService.wsdl -p org.apache.axis2.jaxbri.identityservice -ns2p http://www.example.org/identity=org.apache.axis2.jaxbri.identityservice" />
                                 </java>
                             </tasks>
                         </configuration>
@@ -190,6 +194,7 @@
                                 <source>${project.build.directory}/schema/src</source>
                                 <source>${project.build.directory}/gen/Test01/src</source>
                                 <source>${project.build.directory}/gen/processor/src</source>
+                                <source>${project.build.directory}/gen/identityservice/src</source>
                             </sources>
                         </configuration>
                     </execution>
@@ -236,6 +241,25 @@
                             </resources>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>identityservice-repo</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/repo/identityservice</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>src/test/repo</directory>
+                                </resource>
+                                <resource>
+                                    <directory>${project.build.directory}/gen/identityservice/resources</directory>
+                                    <targetPath>services/identityservice.aar/META-INF</targetPath>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
             <plugin>

Modified: axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl Mon Jul  2 19:34:15 2012
@@ -61,22 +61,21 @@
         <xsl:for-each select="param[not(@type = preceding-sibling::param/@type)]">
             <xsl:if test="@type!=''">
 
-                private org.apache.axiom.om.OMElement toOM(<xsl:value-of select="@type"/> param, boolean optimizeContent)
+                private org.apache.axiom.om.OMElement toOM(<xsl:value-of select="@type"/> param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                     throws org.apache.axis2.AxisFault {
                         org.apache.axiom.om.OMFactory factory = org.apache.axiom.om.OMAbstractFactory.getOMFactory();
 
                         java.lang.Object object = param; <!-- This is necessary to convert primitive types to their corresponding wrapper types (so that we can call getClass()) -->
                         org.apache.axis2.jaxbri.JaxbRIDataSource source = new org.apache.axis2.jaxbri.JaxbRIDataSource( wsContext,
-                                new javax.xml.bind.JAXBElement(new javax.xml.namespace.QName("<xsl:value-of select="qname/@nsuri"/>", "<xsl:value-of select="qname/@localname"/>"),
-                                                               object.getClass(), object));
-                        org.apache.axiom.om.OMNamespace namespace = factory.createOMNamespace("<xsl:value-of select="qname/@nsuri"/>", null);
-                        return factory.createOMElement(source, "<xsl:value-of select="qname/@localname"/>", namespace);
+                                new javax.xml.bind.JAXBElement(elementQName, object.getClass(), object));
+                        org.apache.axiom.om.OMNamespace namespace = factory.createOMNamespace(elementQName.getNamespaceURI(), null);
+                        return factory.createOMElement(source, elementQName.getLocalPart(), namespace);
                     }
 
-                private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="@type"/> param, boolean optimizeContent)
+                private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="@type"/> param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                 throws org.apache.axis2.AxisFault {
                     org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
-                    envelope.getBody().addChild(toOM(param, optimizeContent));
+                    envelope.getBody().addChild(toOM(param, optimizeContent, elementQName));
                     return envelope;
                 }
 

Added: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityLinkingServiceImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityLinkingServiceImpl.java?rev=1356429&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityLinkingServiceImpl.java (added)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityLinkingServiceImpl.java Mon Jul  2 19:34:15 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxbri.identityservice;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.axis2.context.MessageContext;
+
+public class IdentityLinkingServiceImpl implements IdentityLinkingServiceSkeletonInterface {
+    private Map<String,LinkIdentitiesType> map = new HashMap<String,LinkIdentitiesType>();
+
+    public LinkIdentitiesResponseType createLinkedIdentities(LinkIdentitiesType linkIdentities) {
+        assertEquals("LinkIdentities", MessageContext.getCurrentMessageContext().getEnvelope().getSOAPBodyFirstElementLocalName());
+        if (map.containsKey(linkIdentities.getOwningPlatform())) {
+            fail("Already exists");
+        }
+        map.put(linkIdentities.getOwningPlatform(), linkIdentities);
+        LinkIdentitiesResponseType result = new LinkIdentitiesResponseType();
+        result.setOwningPlatform(linkIdentities.getOwningPlatform());
+        return result;
+    }
+
+    public ModifyLinkResponseType modifyLink(LinkIdentitiesType modifyLink) {
+        assertEquals("ModifyLink", MessageContext.getCurrentMessageContext().getEnvelope().getSOAPBodyFirstElementLocalName());
+        if (!map.containsKey(modifyLink.getOwningPlatform())) {
+            fail("Doesn't exist");
+        }
+        map.put(modifyLink.getOwningPlatform(), modifyLink);
+        ModifyLinkResponseType result = new ModifyLinkResponseType();
+        result.setOwningPlatform(modifyLink.getOwningPlatform());
+        return result;
+    }
+
+    public RemoveLinkResponseType removeLink(LinkIdentitiesType removeLink) {
+        assertEquals("RemoveLink", MessageContext.getCurrentMessageContext().getEnvelope().getSOAPBodyFirstElementLocalName());
+        if (!map.containsKey(removeLink.getOwningPlatform())) {
+            fail("Doesn't exist");
+        }
+        map.remove(removeLink.getOwningPlatform());
+        RemoveLinkResponseType result = new RemoveLinkResponseType();
+        result.setOwningPlatform(removeLink.getOwningPlatform());
+        return result;
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityLinkingServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityServiceTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityServiceTest.java?rev=1356429&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityServiceTest.java (added)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityServiceTest.java Mon Jul  2 19:34:15 2012
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxbri.identityservice;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.testutils.UtilServer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Regression test for AXIS2-4197.
+ */
+public class IdentityServiceTest {
+    private static final String ENDPOINT = "http://127.0.0.1:" + UtilServer.TESTING_PORT + "/axis2/services/IdentityLinkingService";
+    
+    @BeforeClass
+    public static void startServer() throws Exception {
+        UtilServer.start(System.getProperty("basedir", ".") + "/target/repo/identityservice");
+        AxisConfiguration axisConfiguration = UtilServer.getConfigurationContext().getAxisConfiguration();
+        AxisService service = axisConfiguration.getService("IdentityLinkingService");
+        service.getParameter(Constants.SERVICE_CLASS).setValue(IdentityLinkingServiceImpl.class.getName());
+        service.setScope(Constants.SCOPE_APPLICATION);
+    }
+    
+    @AfterClass
+    public static void stopServer() throws Exception {
+        UtilServer.stop();
+    }
+    
+    @Test
+    public void test() throws Exception {
+        IdentityLinkingService stub = new IdentityLinkingServiceStub(UtilServer.getConfigurationContext(), ENDPOINT);
+        LinkIdentitiesType linkIdentities = new LinkIdentitiesType();
+        linkIdentities.setOwningPlatform("test");
+        stub.createLinkedIdentities(linkIdentities);
+        stub.modifyLink(linkIdentities);
+        stub.removeLink(linkIdentities);
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/identityservice/IdentityServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identity.xsd
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identity.xsd?rev=1356429&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identity.xsd (added)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identity.xsd Mon Jul  2 19:34:15 2012
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	elementFormDefault="qualified" attributeFormDefault="unqualified"
+	xmlns="http://www.example.org/identity" targetNamespace="http://www.example.org/identity">
+
+	<xs:complexType name="linkIdentitiesResponseType">
+		<xs:sequence>
+			<xs:element name="owningPlatform" type="xs:string"
+				minOccurs="1" maxOccurs="1" nillable="false" />
+		</xs:sequence>
+	</xs:complexType>
+
+
+	<xs:complexType name="modifyLinkResponseType">
+		<xs:complexContent>
+			<xs:extension base="linkIdentitiesResponseType">
+			</xs:extension>
+		</xs:complexContent>
+	</xs:complexType>
+
+	<xs:complexType name="removeLinkResponseType">
+		<xs:complexContent>
+			<xs:extension base="linkIdentitiesResponseType">
+			</xs:extension>
+		</xs:complexContent>
+	</xs:complexType>
+
+
+	<xs:complexType name="removeIdentityResponseType">
+		<xs:sequence>
+			<xs:element name="owningPlatform" type="xs:string"
+				minOccurs="1" maxOccurs="1" nillable="false" />
+		</xs:sequence>
+	</xs:complexType>
+
+
+	<xs:complexType name="linkIdentitiesType">
+		<xs:sequence>
+			<xs:element name="owningPlatform" type="xs:string"
+				minOccurs="1" maxOccurs="1" nillable="false" />
+		</xs:sequence>
+	</xs:complexType>
+
+
+	<xs:complexType name="linkIdentitiesGuidResponseType">
+		<xs:sequence>
+			<xs:element name="owningPlatform" type="xs:string"
+				minOccurs="1" maxOccurs="1" nillable="false" />
+		</xs:sequence>
+	</xs:complexType>
+
+	<xs:complexType name="multipleLinkIdentitiesType">
+		<xs:sequence>
+			<xs:element name="multipleIdentityLink" type="linkIdentitiesType"
+				minOccurs="0" maxOccurs="unbounded" />
+		</xs:sequence>
+	</xs:complexType>
+
+	<xs:complexType name="multipleLinkIdentitiesGuidResponseType">
+		<xs:sequence>
+			<xs:element name="multipleLinkIdentitiesGuidResponse"
+				type="linkIdentitiesGuidResponseType" minOccurs="0" maxOccurs="unbounded" />
+		</xs:sequence>
+	</xs:complexType>
+
+
+	<xs:element name="LinkIdentities" type="linkIdentitiesType" />
+	<xs:element name="LinkIdentitiesResponse" type="linkIdentitiesResponseType" />
+	<xs:element name="ModifyLink" type="linkIdentitiesType" />
+	<xs:element name="ModifyLinkResponse" type="modifyLinkResponseType" />
+
+	<xs:element name="RemoveLink" type="linkIdentitiesType" />
+	<xs:element name="RemoveLinkResponse" type="removeLinkResponseType" />
+
+</xs:schema>

Added: axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identityService.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identityService.wsdl?rev=1356429&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identityService.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/identityService.wsdl Mon Jul  2 19:34:15 2012
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+	xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://www.example.org/identity"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://www.example.org/identity">
+    <wsdl:types>
+        <xs:schema>
+            <xs:import namespace="http://www.example.org/identity" schemaLocation="identity.xsd"/>
+        </xs:schema>
+    </wsdl:types>
+
+	<wsdl:message name="linkIdentitiesRequest">
+	<wsdl:part name="parameters" element="LinkIdentities" />
+	</wsdl:message>
+
+	<wsdl:message name="linkIdentitiesResponse">
+		<wsdl:part name="parameters" element="LinkIdentitiesResponse" />
+	</wsdl:message>
+	
+	<wsdl:message name="removeLinkRequest">
+		<wsdl:part name="parameters" element="RemoveLink" />
+	</wsdl:message>
+	
+	<wsdl:message name="removeLinkResponse">
+		<wsdl:part name="parameters" element="RemoveLinkResponse" />
+	</wsdl:message>
+	
+	<wsdl:message name="modifyLinkRequest">
+		<wsdl:part name="parameters" element="ModifyLink" />
+	</wsdl:message>
+	
+	<wsdl:message name="modifyLinkResponse">
+		<wsdl:part name="parameters" element="ModifyLinkResponse" />
+	</wsdl:message>
+	
+	<wsdl:portType name="identityLinking">
+		<wsdl:operation name="CreateLinkedIdentities">
+			<wsdl:input message="linkIdentitiesRequest" />
+			<wsdl:output message="linkIdentitiesResponse" />
+		</wsdl:operation>
+		<wsdl:operation name="ModifyLink">
+			<wsdl:input message="modifyLinkRequest" />
+			<wsdl:output message="modifyLinkResponse" />
+		</wsdl:operation>
+
+		<wsdl:operation name="RemoveLink">
+			<wsdl:input message="removeLinkRequest" />
+			<wsdl:output message="removeLinkResponse" />
+		</wsdl:operation>
+	</wsdl:portType>
+
+	<wsdl:binding name="IdentityLinkingBinding" type="identityLinking">
+		<soap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="CreateLinkedIdentities">
+			<soap:operation />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+		<wsdl:operation name="ModifyLink">
+			<soap:operation />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+
+		<wsdl:operation name="RemoveLink">
+			<soap:operation />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:service name="IdentityLinkingService">
+		<!-- connect it to the binding "IdentityLinkingBinding" above -->
+		<wsdl:port name="IdentityLinkingPort" binding="IdentityLinkingBinding">
+			<soap:address location="http://localhost:8080/services/IdentityLinkingPort" />
+			<!-- give the binding an network address -->
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>

Modified: axis/axis2/java/core/trunk/modules/jibx/src/main/resources/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jibx/src/main/resources/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jibx/src/main/resources/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/jibx/src/main/resources/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl Mon Jul  2 19:34:15 2012
@@ -116,7 +116,7 @@
   
   <xsl:template name="toEnvelope-method">
         
-        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="@type"/> param, boolean optimizeContent) {
+        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="@type"/> param, boolean optimizeContent, javax.xml.namespace.QName elementQName) {
             org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
             if (param != null){
                 envelope.getBody().addChild(toOM(param, factory, optimizeContent));

Modified: axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl?rev=1356429&r1=1356428&r2=1356429&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl (original)
+++ axis/axis2/java/core/trunk/modules/xmlbeans/src/org/apache/axis2/xmlbeans/template/XmlbeansDatabindingTemplate.xsl Mon Jul  2 19:34:15 2012
@@ -153,7 +153,7 @@
                             </xsl:when>
                             <xsl:otherwise>
                                 <!-- Assumption - the parameter is always an XMLBeans -->
-                                private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="$inputElementType"/> param, boolean optimizeContent)
+                                private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="$inputElementType"/> param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                                 throws org.apache.axis2.AxisFault{
                                 org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
                                 if (param != null){
@@ -182,7 +182,7 @@
 
                         <!-- Assumption - This is an XMLBeans element-->
                         <xsl:if test="generate-id($outElement) = generate-id(key('paramsOut', $outElementType)[1])">
-                            private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="../../param[@type!='' and @direction='out' and @opname=$opname]/@type"/> param, boolean optimizeContent)
+                            private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, <xsl:value-of select="../../param[@type!='' and @direction='out' and @opname=$opname]/@type"/> param, boolean optimizeContent, javax.xml.namespace.QName elementQName)
                             throws org.apache.axis2.AxisFault {
                             org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
                             if (param != null){