You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ds...@apache.org on 2006/10/09 04:37:30 UTC

svn commit: r454255 - in /webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx: CodeGenerationUtility.java template/JibXDatabindingTemplate.xsl

Author: dsosnoski
Date: Sun Oct  8 19:37:29 2006
New Revision: 454255

URL: http://svn.apache.org/viewvc?view=rev&rev=454255
Log:
Correct errors in JiBX unwrapped support (1.1)

Modified:
    webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java
    webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl

Modified: webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java?view=diff&rev=454255&r1=454254&r2=454255
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java (original)
+++ webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/CodeGenerationUtility.java Sun Oct  8 19:37:29 2006
@@ -42,7 +42,6 @@
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
 import org.apache.axis2.wsdl.util.Constants;
 import org.apache.axis2.wsdl.util.MessagePartInformationHolder;
-import org.apache.bcel.generic.Type;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
@@ -142,6 +141,12 @@
                 throw new RuntimeException("invalid jibx binding definition file " + path);
             }
             
+            // make sure classes will be generated for abstract mappings
+            boolean unwrap = !codeGenConfig.isParametersWrapped();
+            if (unwrap && !binding.isForceClasses()) {
+                throw new RuntimeException("unwrapped binding must use force-classes='true' option in " + path);
+            }
+            
             // create table with all built-in format definitions
             Map simpleTypeMap = new HashMap();
             buildFormat("byte", "byte",
@@ -200,7 +205,6 @@
             // configure handling for all operations of service
             codeGenConfig.setTypeMapper(new NamedParameterTypeMapper());
             Iterator operations = codeGenConfig.getAxisService().getOperations();
-            boolean unwrap = !codeGenConfig.isParametersWrapped();
             Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
             int opindex = 0;
             Map typeMappedClassMap = new HashMap();
@@ -401,7 +405,8 @@
                     FormatElement format = (FormatElement)simpleTypeMap.get(typename);
                     if (format == null) {
                         throw new RuntimeException("Cannot unwrap element " +
-                            qname + ": no format definition found for child element " + itemname);
+                            qname + ": no format definition found for type " +
+                            typename + " (used by element " + itemname + ')');
                     }
                     javatype = format.getTypeName();
                     param.setAttribute("form", "simple");
@@ -421,7 +426,8 @@
                     MappingElement mapping = (MappingElement)complexTypeMap.get(typename);
                     if (mapping == null) {
                         throw new RuntimeException("Cannot unwrap element " +
-                            qname + ": no abstract mapping definition found for child element " + itemname);
+                            qname + ": no abstract mapping definition found for type " +
+                            typename + " (used by element " + itemname + ')');
                     }
                     Integer tindex = (Integer)typeMappedClassMap.get(typename);
                     if (tindex == null) {
@@ -440,7 +446,7 @@
                     fulltype += "[]";
                     isobj = false;
                 }
-                param.setAttribute("object", Boolean.toString(isarray));
+                param.setAttribute("object", Boolean.toString(isobj));
                 if (isout) {
                     wrappertype = fulltype;
                 } else {

Modified: webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl?view=diff&rev=454255&r1=454254&r2=454255
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl (original)
+++ webservices/axis2/branches/java/1_1/modules/jibx/src/org/apache/axis2/jibx/template/JibXDatabindingTemplate.xsl Sun Oct  8 19:37:29 2006
@@ -309,11 +309,11 @@
     <xsl:if test="out-wrapper/@empty='false'">
                 org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient
                     .getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-                org.apache.axiom.om.OMElement result = _returnMessageContext.getEnvelope().getFirstElement();
+                org.apache.axiom.om.OMElement result = _returnMessageContext.getEnvelope().getBody().getFirstElement();
                 if (result != null &amp;&amp; "<xsl:value-of select='out-wrapper/@name'/>".equals(result.getLocalName()) &amp;&amp;
                     "<xsl:value-of select='out-wrapper/@ns'/>".equals(result.getNamespace().getNamespaceURI())) {
                     org.jibx.runtime.impl.UnmarshallingContext uctx = getNewUnmarshalContext(result);
-                    uctx.next();
+                    uctx.parsePastStartTag("<xsl:value-of select='out-wrapper/@ns'/>", "<xsl:value-of select='out-wrapper/@name'/>");
                     int index;
       <xsl:apply-templates select="out-wrapper/return-element" mode="interface-implementation"/>
                     return <xsl:value-of select="out-wrapper/return-element/@java-name"/>;
@@ -383,10 +383,10 @@
   </xsl:template>
   
   <!-- Invoked to get the operation index number for a method. -->
-  <xsl:template match="method" mode="get-index"><xsl:value-of select="position()-1"/></xsl:template>
+  <xsl:template match="method" mode="get-index"><xsl:value-of select="count(preceding-sibling::method)"/></xsl:template>
   
   <!-- Invoked to get the operation action for a method. -->
-  <xsl:template match="method" mode="get-action"><xsl:value-of select="@action"/></xsl:template>
+  <xsl:template match="method" mode="get-action"><xsl:value-of select="@soapaction"/></xsl:template>
   
   <!-- Generate code for a particular parameter element in a client stub method -->
   <xsl:template match="parameter-element" mode="interface-implementation">
@@ -406,7 +406,7 @@
     <xsl:choose>
       <xsl:when test="@optional='true'"></xsl:when>
       <xsl:when test="@nillable='true'">
-        child = factory.createOMElement("<xsl:value-of select='@ns'/>", "<xsl:value-of select='@name'/>", "");
+        child = factory.createOMElement("<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "");
         org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
         child.declareNamespace(xsins);
         child.addAttribute("nil", "true", xsins);
@@ -422,7 +422,7 @@
     <xsl:choose>
       <xsl:when test="@object='true' and @nillable='true'">
             if (_item == null) {
-                child = factory.createOMElement("<xsl:value-of select='@ns'/>", "<xsl:value-of select='@name'/>", "");
+                child = factory.createOMElement("<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "");
                 org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
                 child.declareNamespace(xsins);
                 child.addAttribute("nil", "true", xsins);
@@ -451,7 +451,7 @@
     <xsl:choose>
       <xsl:when test="@object='true' and @nillable='true'">
         if (<xsl:value-of select="@java-name"/> == null) {
-            child = factory.createOMElement("<xsl:value-of select='@ns'/>", "<xsl:value-of select='@name'/>", "");
+            child = factory.createOMElement("<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "");
             org.apache.axiom.om.OMNamespace xsins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
             child.declareNamespace(xsins);
             child.addAttribute("nil", "true", xsins);
@@ -477,15 +477,15 @@
   <xsl:template name="serialize-value-to-child">
     <xsl:choose>
       <xsl:when test="@java-type='java.lang.String' and @serializer=''">
-        child = factory.createOMElement("<xsl:value-of select='@ns'/>", "<xsl:value-of select='@name'/>", "");
+        child = factory.createOMElement("<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "");
         child.setText(<xsl:call-template name="parameter-or-array-item"/>);
       </xsl:when>
       <xsl:when test="@form='simple' and @serializer=''">
-        child = factory.createOMElement("<xsl:value-of select='@ns'/>", "<xsl:value-of select='@name'/>", "");
+        child = factory.createOMElement("<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "");
         child.setText(<xsl:call-template name="parameter-or-array-item"/>.toString());
       </xsl:when>
       <xsl:when test="@form='simple'">
-        child = factory.createOMElement("<xsl:value-of select='@ns'/>", "<xsl:value-of select='@name'/>", "");
+        child = factory.createOMElement("<xsl:value-of select='@name'/>", "<xsl:value-of select='@ns'/>", "");
         child.setText(<xsl:value-of select="@serializer"/>(<xsl:call-template name="parameter-or-array-item"/>));
       </xsl:when>
       <xsl:when test="@form='complex'">
@@ -556,7 +556,7 @@
   <!-- Called by "initialize-binding" template to initialize mapped class index fields. -->
   <xsl:template match="abstract-type" mode="set-index-fields">
          _type_index<xsl:value-of select="@type-index"/> = (bindingFactory == null) ?
-            -1 : bindingFactory.getTypeIndex("{<xsl:value-of select="@ns"/>}<xsl:value-of select="@name"/>");
+            -1 : bindingFactory.getTypeIndex("{<xsl:value-of select="@ns"/>}:<xsl:value-of select="@name"/>");
   </xsl:template>
   
   
@@ -581,6 +581,7 @@
     <xsl:if test="@nillable='true'">
           }
     </xsl:if>
+          uctx.next();
       }
       <xsl:value-of select="@java-name"/> = (<xsl:value-of select="@java-type"/>[])org.jibx.runtime.Utility.resizeArray(index, <xsl:value-of select="@java-name"/>);
     <xsl:if test="@optional!='true'">
@@ -628,7 +629,7 @@
         <xsl:value-of select="@deserializer"/>(uctx.parseElementText("<xsl:value-of select="@ns"/>", "<xsl:value-of select="@name"/>"))
       </xsl:when>
       <xsl:when test="@form='complex'">
-        uctx.getUnmarshaller(_type_index<xsl:value-of select="@type-index"/>).unmarshal(null, uctx)
+        uctx.getUnmarshaller(_type_index<xsl:value-of select="@type-index"/>).unmarshal(new <xsl:value-of select="@java-type"/>(), uctx)
       </xsl:when>
     </xsl:choose>
   </xsl:template>



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