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 na...@apache.org on 2008/07/09 17:19:42 UTC

svn commit: r675224 - in /webservices/axis/trunk/c: include/axis/client/ src/cbindings/client/ src/engine/client/ src/soap/ src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ src/wsdl/org/apache/axis/wsdl/wsdl2ws/...

Author: nadiramra
Date: Wed Jul  9 08:19:41 2008
New Revision: 675224

URL: http://svn.apache.org/viewvc?rev=675224&view=rev
Log:
AXISCPP-458 - Implement doc/literal wrapper-style correctly, add support for non-wrapper style when wrapper-style cannot be done or when user requests it. Part II of fix to ensure that wrapper attributes are handled correctly.

Modified:
    webservices/axis/trunk/c/include/axis/client/Call.h
    webservices/axis/trunk/c/include/axis/client/Call.hpp
    webservices/axis/trunk/c/src/cbindings/client/CallC.cpp
    webservices/axis/trunk/c/src/engine/client/Call.cpp
    webservices/axis/trunk/c/src/soap/SoapMethod.cpp
    webservices/axis/trunk/c/src/soap/SoapMethod.h
    webservices/axis/trunk/c/src/soap/SoapSerializer.cpp
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java

Modified: webservices/axis/trunk/c/include/axis/client/Call.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/client/Call.h?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/client/Call.h (original)
+++ webservices/axis/trunk/c/include/axis/client/Call.h Wed Jul  9 08:19:41 2008
@@ -395,6 +395,19 @@
 	const char * pchNamespace);
 
 /**
+ * Method to set the remote method name in non-wrapper style operation.
+ *
+ * @param pchOperation null terminated character string that contains the
+ * request tag name. i.e. @n
+ * m_pCall->setOperation( "doBenchRequest", Axis_URI_BenchDataType);@n
+ * @param pchNamespace null terminated character string that contains the
+ * namespace for the operation.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscCallSetOperationUnwrapped(AXISCHANDLE call, const char * pchOperation, 
+	const char * pchNamespace);
+
+/**
  * Method to set the endpoint URI for the service.
  *
  * @param pchEndpointURI null terminated character string that contains the

Modified: webservices/axis/trunk/c/include/axis/client/Call.hpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/include/axis/client/Call.hpp?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/client/Call.hpp (original)
+++ webservices/axis/trunk/c/include/axis/client/Call.hpp Wed Jul  9 08:19:41 2008
@@ -403,6 +403,20 @@
                                 const char * pchNamespace);
 
     /**
+     * Method to set the remote method name.
+     *
+     * @param pchOperation null terminated character string that contains the
+     * request tag name. i.e. @n
+     * m_pCall->setOperation( "doBenchRequest", Axis_URI_BenchDataType);@n
+     * @param pchNamespace null terminated character string that contains the
+     * namespace for the operation.
+     * @param bIsWrapperStyle whether operation is wrapper-style or not.
+     */
+    void AXISCALL setOperation( const char * pchOperation,
+                                const char * pchNamespace,
+                                bool bIsWrapperStyle);    
+    
+    /**
      * Method to set the endpoint URI for the service.
      *
      * @param pchEndpointURI null terminated character string that contains the

Modified: webservices/axis/trunk/c/src/cbindings/client/CallC.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/cbindings/client/CallC.cpp?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/client/CallC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/client/CallC.cpp Wed Jul  9 08:19:41 2008
@@ -560,6 +560,27 @@
 }
 
 AXISC_STORAGE_CLASS_INFO 
+void axiscCallSetOperationUnwrapped(AXISCHANDLE call, 
+                                    const char * pchOperation, 
+                                    const char * pchNamespace) 
+{
+    Call *c = (Call*)call;
+    
+    try
+    {
+        c->setOperation(pchOperation, pchNamespace, false);
+    }
+    catch ( AxisException& e  )
+    {
+        processException(c, e);
+    }
+    catch ( ... )
+    {
+        axiscAxisInvokeExceptionHandler(-1, "Unrecognized exception thrown.", NULL, NULL);
+    }
+}
+
+AXISC_STORAGE_CLASS_INFO 
 int axiscCallSetEndpointURI(AXISCHANDLE call, 
                             const char * pchEndpointURI) 
 {

Modified: webservices/axis/trunk/c/src/engine/client/Call.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/engine/client/Call.cpp?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/engine/client/Call.cpp (original)
+++ webservices/axis/trunk/c/src/engine/client/Call.cpp Wed Jul  9 08:19:41 2008
@@ -34,7 +34,7 @@
 #include "../../soap/HeaderBlock.h"
 #include "../../common/AxisGenException.h"
 #include "../../soap/Attribute.h"
-
+#include "../../soap/SoapMethod.h"
 
 extern AXIS_CPP_NAMESPACE_PREFIX AxisConfig* g_pConfig;
 
@@ -133,8 +133,18 @@
 void Call::setOperation (const char* pchOperation, 
                          const char* pchNamespace)
 {
+    setOperation(pchOperation, pchNamespace, true);
+}
+
+void Call::setOperation (const char* pchOperation, 
+                         const char* pchNamespace,
+                         bool bIsWrapperStyle)
+{
     m_pIWSSZ->createSoapMethod (pchOperation, pchNamespace);
     m_pAxisEngine->getMessageData()->setOperationName(pchOperation);
+    
+    SoapMethod* sm = getSOAPSerializer()->getSOAPMethod();
+    sm->setWrapperStyle(bIsWrapperStyle); 
 }
 
 void Call::addParameter( void * pValue, 

Modified: webservices/axis/trunk/c/src/soap/SoapMethod.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/soap/SoapMethod.cpp?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/soap/SoapMethod.cpp (original)
+++ webservices/axis/trunk/c/src/soap/SoapMethod.cpp Wed Jul  9 08:19:41 2008
@@ -29,6 +29,7 @@
 SoapMethod::
 SoapMethod()
 {
+	reset();
 }
 
 SoapMethod::
@@ -41,19 +42,28 @@
 void SoapMethod::
 setPrefix(const AxisChar* prefix)
 {
-    m_strPrefix = prefix;
+	if (NULL == prefix)
+		m_strPrefix = "";
+	else
+		m_strPrefix = prefix;
 }
 
 void SoapMethod::
 setLocalName(const AxisChar* localname)
 {
-    m_strLocalname = localname;
+	if (NULL == localname)
+		m_strLocalname = "";
+	else
+		m_strLocalname = localname;
 }
 
 void SoapMethod::
 setURI(const AxisChar* uri)
 {
-    m_strUri = uri;
+	if (NULL == uri)
+		m_strUri = "";
+	else
+		m_strUri = uri;
 }
 
 void SoapMethod::
@@ -82,7 +92,10 @@
             if(iStatus==AXIS_FAIL)
                 break;
             
-            pSZ.serialize(">\n", NULL);
+            // If not wrapper style, then end tag will be added by bean. 
+            // This is a hack in order to keep backward compatibility.
+            if (m_isWrapperStyle)
+            	pSZ.serialize(">\n", NULL);
 
             // push the current NS to the NS stack
             pSZ.getNamespacePrefix(m_strUri.c_str());
@@ -165,7 +178,8 @@
 int SoapMethod::
 addAttribute(Attribute *pAttribute)
 {
-    m_attributes.push_back(pAttribute);
+	if (pAttribute)
+		m_attributes.push_back(pAttribute);
 
     return AXIS_SUCCESS;
 }
@@ -187,6 +201,7 @@
 int SoapMethod::
 reset()
 {
+	m_isWrapperStyle = true;
     m_strUri = "";
     m_strLocalname = "";
     m_strPrefix = "";

Modified: webservices/axis/trunk/c/src/soap/SoapMethod.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/soap/SoapMethod.h?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/soap/SoapMethod.h (original)
+++ webservices/axis/trunk/c/src/soap/SoapMethod.h Wed Jul  9 08:19:41 2008
@@ -69,6 +69,7 @@
     AxisString m_strLocalname;
     AxisString m_strUri;
     list<Param*> m_OutputParams;
+    bool m_isWrapperStyle;
 
 public:    
     int reset();
@@ -84,6 +85,8 @@
     void addOutputParam(Param *param);
     void setURI(const AxisChar* uri);
     void setLocalName(const AxisChar* localname);
+    void setWrapperStyle(bool bIsWrapperStyle) { m_isWrapperStyle = bIsWrapperStyle; }
+    bool isWrapperStyle() { return m_isWrapperStyle; }
     void setPrefix(const AxisChar* prefix);
     SoapMethod();
     virtual ~SoapMethod();

Modified: webservices/axis/trunk/c/src/soap/SoapSerializer.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/soap/SoapSerializer.cpp?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/soap/SoapSerializer.cpp (original)
+++ webservices/axis/trunk/c/src/soap/SoapSerializer.cpp Wed Jul  9 08:19:41 2008
@@ -513,23 +513,24 @@
 int SoapSerializer::
 createSoapMethod( const AxisChar * sLocalName, const AxisChar * sURI)
 {
-    SoapMethod * pMethod = NULL;
-    if( !(m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod))
+	if (NULL == m_pSoapEnvelope || NULL == m_pSoapEnvelope->m_pSoapBody)
+		return AXIS_FAIL;
+		
+    SoapMethod * pMethod = m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod;
+    if (pMethod == NULL)
     {
         pMethod = new SoapMethod();
         setSoapMethod( pMethod);
     }
-    else
-    {
-        pMethod = m_pSoapEnvelope->m_pSoapBody->m_pSoapMethod;
-        pMethod->clearOutParams();
-    }
+    
+    // Ensure everything is cleared out if using existing method object.
+    pMethod->reset();
 
     pMethod->setLocalName( sLocalName);
     pMethod->setPrefix( getNamespacePrefix( sURI));
     pMethod->setURI( sURI);
 
-    return AXIS_SUCCESS;  // Can it only be successful?
+    return AXIS_SUCCESS;
 }
 
 int SoapSerializer::

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java Wed Jul  9 08:19:41 2008
@@ -108,8 +108,7 @@
         {
             CUtils.printBlockComment(writer, "No attributes or elements to serialize.");
         
-            if (!type.isUnwrappedInputType())
-               writer.write("\taxiscSoapSerializerSerialize(pSZ,\">\", NULL);\n");
+            writer.write("\taxiscSoapSerializerSerialize(pSZ,\">\", NULL);\n");
 
             writeSerializeExtensionCode();
             
@@ -130,8 +129,8 @@
         
         writer.write("\tif ( param == NULL )\n\t{\n");
         writer.write("\t\taxiscSoapSerializerSerializeAsAttribute(pSZ, \"xsi:nil\", 0, (void*)&(xsdc_boolean_true), XSDC_BOOLEAN);\n");
-        if (!type.isUnwrappedInputType())
-            writer.write("\t\taxiscSoapSerializerSerialize(pSZ, \">\", NULL);\n");
+
+        writer.write("\t\taxiscSoapSerializerSerialize(pSZ, \">\", NULL);\n");
         writer.write("\t\treturn AXISC_SUCCESS;\n");
         writer.write("\t}\n");
         
@@ -199,7 +198,7 @@
             writer.write(", NULL);\n\t}\n");
         }               
         
-        if (wscontext.getWrapInfo().getWrapperStyle().equals("document") && !type.isUnwrappedInputType())
+        if (wscontext.getWrapInfo().getWrapperStyle().equals("document"))
             writer.write("\taxiscSoapSerializerSerialize(pSZ, \">\", 0);\n");
         
         //=============================================================================

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java Wed Jul  9 08:19:41 2008
@@ -366,46 +366,12 @@
         if (namespaceURI == null)
             namespaceURI = "";
              
-        writer.write("\taxiscCallSetOperation(call, \""
-            + minfo.getMethodname() + "\", \""
+        if (minfo.isUnwrapped())
+            writer.write("\taxiscCallSetOperationUnwrapped(call, \"");
+        else
+            writer.write("\taxiscCallSetOperation(call, \"");
+        writer.write( minfo.getMethodname() + "\", \""
             + namespaceURI + "\");\n");
-
-        // Add attributes to soap method
-        boolean commentIssued=false;
-        for (int i = 0; i < paramsB.size (); i++)
-        {
-            ParameterInfo param = (ParameterInfo) paramsB.get (i);
-            
-            // Skip non-attributes
-            if (!param.isAttribute ())
-                continue;
-            
-            if (!commentIssued)
-            {
-                commentIssued = true;
-                CUtils.printBlockComment(writer, "Add attributes to soap method.");
-            }
-            else
-                writer.write ("\n");
-            
-            // Process attributes
-            String elementType = param.getElementName ().getLocalPart ();
-    
-            if ("string".equals (elementType))
-            {
-                writer.write ("\taxiscCallSetSOAPMethodAttribute(call, \""
-                      + param.getParamNameAsSOAPString () + "\", \"\", Value" + i + ");\n");
-            }
-            else if ("int".equals (elementType))
-            {
-                writer.write ("\t{\n");
-                writer.write ("\t\tchar buffer[20];\n");
-                writer.write ("\t\tsprintf(buffer,\"%d\", Value" + i + ");\n");
-                writer.write ("\t\taxiscCallSetSOAPMethodAttribute(call, \"" +
-                       param.getParamNameAsSOAPString () + "\", \"\", buffer);\n");
-                writer.write ("\t}\n");
-            }
-        } // end for-loop
         
         // new calls from stub base
         CUtils.printBlockComment(writer, "Apply SSL configuration properties and user-set SOAP headers.");        
@@ -413,7 +379,7 @@
         writer.write ("\taxiscStubApplyUserPreferences(stub);\n");
         
         // Process elements
-        commentIssued=false;
+        boolean commentIssued=false;
         String tab2;
         for (int i = 0; i < paramsB.size(); i++)
         {

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java Wed Jul  9 08:19:41 2008
@@ -331,8 +331,7 @@
         {
             CUtils.printBlockComment(writer, "No attributes or elements to serialize.");
             
-            if (!type.isUnwrappedInputType())
-                writer.write("\tpSZ->serialize(\">\", NULL);\n");
+            writer.write("\tpSZ->serialize(\">\", NULL);\n");
 
             writeSerializeExtensionCode();
             
@@ -352,8 +351,7 @@
         writer.write("\tif ( param == NULL )\n\t{\n");
         writer.write("\t\tpSZ->serializeAsAttribute( \"xsi:nil\", 0, (void*)&(xsd_boolean_true), XSD_BOOLEAN);\n");
         
-        if (!type.isUnwrappedInputType())
-            writer.write("\t\tpSZ->serialize( \">\", NULL);\n");
+        writer.write("\t\tpSZ->serialize( \">\", NULL);\n");
         writer.write("\t\treturn AXIS_SUCCESS;\n");
         writer.write("\t}\n");
         
@@ -423,7 +421,7 @@
             writer.write(", NULL);\n\t}\n");
         }               
         
-        if (wscontext.getWrapInfo().getWrapperStyle().equals("document") && !type.isUnwrappedInputType())
+        if (wscontext.getWrapInfo().getWrapperStyle().equals("document"))
             writer.write("\tpSZ->serialize( \">\", 0);\n");
         
         //=============================================================================

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java?rev=675224&r1=675223&r2=675224&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java Wed Jul  9 08:19:41 2008
@@ -367,50 +367,14 @@
         if (namespaceURI == null)
             namespaceURI = "";
 
+        String iswrapperstyle = "true";
+        if (minfo.isUnwrapped())
+            iswrapperstyle = "false";
+        
          writer.write( "\t\tm_pCall->setOperation(\""
                 + minfo.getMethodname() + "\", \""
-                + namespaceURI + "\");\n");
-        
-        //=============================================================================
-        // Add attributes to soap method
-        //=============================================================================        
-                   
-        boolean commentIssued=false;
-        for (int i = 0; i < paramsB.size (); i++)
-        {
-            ParameterInfo param = (ParameterInfo) paramsB.get (i);
-            
-            // Skip non-attributes
-            if (!param.isAttribute ())
-                continue;
+                + namespaceURI + "\", " + iswrapperstyle + ");\n");
             
-            if (!commentIssued)
-            {
-                commentIssued = true;
-                CUtils.printBlockComment(writer, "Add attributes to soap method.");
-            }
-            else
-                writer.write ("\n");
-            
-            // Process attributes
-            String elementType = param.getElementName ().getLocalPart ();
-    
-            if ("string".equals (elementType))
-            {
-                writer.write ("\t\tm_pCall->setSOAPMethodAttribute(\""
-                      + param.getParamNameAsSOAPString () + "\", \"\", Value" + i + ");\n");
-            }
-            else if ("int".equals (elementType))
-            {
-                writer.write ("\t\t{\n");
-                writer.write ("\t\t\tchar buffer[20];\n");
-                writer.write ("\t\t\tsprintf(buffer,\"%d\", Value" + i + ");\n");
-                writer.write ("\t\t\tm_pCall->setSOAPMethodAttribute(\"" +
-                       param.getParamNameAsSOAPString () + "\", \"\", buffer);\n");
-                writer.write ("\t\t}\n");
-            }
-        } // end for-loop
-    
         //=============================================================================
         // Apply user specified properties
         //=============================================================================        
@@ -423,7 +387,7 @@
         // Process elements
         //=============================================================================        
 
-        commentIssued=false;
+        boolean commentIssued=false;
         String tab2;
         for (int i = 0; i < paramsB.size (); i++)
         {