axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r1234275 - in /axis/axis1/c/trunk: include/axis/client/Stub.h include/axis/client/Stub.hpp src/cbindings/client/StubC.cpp src/engine/client/Stub.cpp
Date Sat, 21 Jan 2012 06:38:41 GMT
Author: nadiramra
Date: Sat Jan 21 06:38:40 2012
New Revision: 1234275

URL: http://svn.apache.org/viewvc?rev=1234275&view=rev
Log:
AXISCPP-712 and AXISCPP-1081, ability to add attributes to SOAP header and SOAP body. 

Modified:
    axis/axis1/c/trunk/include/axis/client/Stub.h
    axis/axis1/c/trunk/include/axis/client/Stub.hpp
    axis/axis1/c/trunk/src/cbindings/client/StubC.cpp
    axis/axis1/c/trunk/src/engine/client/Stub.cpp

Modified: axis/axis1/c/trunk/include/axis/client/Stub.h
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/include/axis/client/Stub.h?rev=1234275&r1=1234274&r2=1234275&view=diff
==============================================================================
--- axis/axis1/c/trunk/include/axis/client/Stub.h (original)
+++ axis/axis1/c/trunk/include/axis/client/Stub.h Sat Jan 21 06:38:40 2012
@@ -565,11 +565,84 @@ void axiscStubCheckForExtraneousElements
  * @param maxCount how many redirects to follow.  Default is 1.  A value less than 1
  *                 is the same as setting handleRedirect to false.
  *
- * @return 0=success; non-zero is failure.
  */
 AXISC_STORAGE_CLASS_INFO
 void axiscStubSetTransportAutoRedirect(AXISCHANDLE stub, AxiscBool handleRedirect, int maxCount);
 
+/**
+ * Add namespace to SOAP header.
+ *
+ * @param pUri The namespace uri .
+ * @param pPrefix The prefix to associate with the uri.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddNamespaceToSOAPHeader(AXISCHANDLE stub,
+        const AxiscChar * pUri,
+        const AxiscChar * pPrefix);
+
+/**
+ * Clears SOAP header namespaces.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPHeaderNamespaces(AXISCHANDLE stub);
+
+/**
+ * Add attribute to SOAP header.
+ *
+ * @param pLocalname The local name of the Attribute.
+ * @param pPrefix The prefix of the Attribute.
+ * @param pValue The value of the Attribute.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddAttributeToSOAPHeader(AXISCHANDLE stub,
+        const AxiscChar * pLocalname,
+        const AxiscChar * pPrefix,
+        const AxiscChar * pValue);
+
+/**
+ * Clears SOAP header attributes.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPHeaderAttributes(AXISCHANDLE stub);
+
+/**
+ * Add namespace to SOAP body.
+ *
+ * @param pUri The namespace uri .
+ * @param pPrefix The prefix to associate with the uri.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddNamespaceToSOAPBody(AXISCHANDLE stub,
+        const AxiscChar * pUri,
+        const AxiscChar * pPrefix);
+
+/**
+ * Clears SOAP body namespaces.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPBodyNamespaces(AXISCHANDLE stub);
+
+/**
+ * Add attribute to SOAP body.
+ *
+ * @param pLocalname The local name of the Attribute.
+ * @param pPrefix The prefix of the Attribute.
+ * @param pUri The namespace uri of the Attribute.
+ * @param pValue The value of the Attribute.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddAttributeToSOAPBody(AXISCHANDLE stub,
+        const AxiscChar * pLocalname,
+        const AxiscChar * pPrefix,
+        const AxiscChar * pValue);
+
+/**
+ * Clears SOAP body attributes.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPBodyAttributes(AXISCHANDLE stub);
+
+
 #ifdef __cplusplus
  }
 #endif

Modified: axis/axis1/c/trunk/include/axis/client/Stub.hpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/include/axis/client/Stub.hpp?rev=1234275&r1=1234274&r2=1234275&view=diff
==============================================================================
--- axis/axis1/c/trunk/include/axis/client/Stub.hpp (original)
+++ axis/axis1/c/trunk/include/axis/client/Stub.hpp Sat Jan 21 06:38:40 2012
@@ -30,28 +30,29 @@
 #include <stdarg.h>
 
 #include <axis/client/Call.hpp>
+
 #include <vector>
 
 using namespace std;
 
+
 /**
  * @class Stub
  *
  * @brief This is the client Stub base class to be inherited by all stub
- *        classes genarated by WSDL2WS tool. This class acts as the interface
+ *        classes generated by WSDL2WS tool. This class acts as the interface
  *        between the users and the Axis C++ engine (client side). Programmer
  *        can use the API defined here to enrich the client application
  *        functionality. Setting transport properties, setting SOAP headers,
  *        setting connection timeout and specifying a proxy on the client stub
  *        is facilitated with this interface.
  *
- * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
- * @author Roshan Weerasuriya (roshan@opensource.lk, roshanw@jkcsworld.com)
- * @author Susantha Kumara (susantha@opensource.lk, skumara@virtusa.com)
  */
 
 AXIS_CPP_NAMESPACE_START
 
+class IAttribute;
+
 class STORAGE_CLASS_INFO Stub
 {
   public:
@@ -482,6 +483,65 @@ class STORAGE_CLASS_INFO Stub
     */
     void deleteSOAPHeaderBlock(IHeaderBlock* pHeaderBlock);
 
+    /**
+     * Add namespace to SOAP header.
+     *
+     * @param pUri The namespace uri .
+     * @param pPrefix The prefix to associate with the uri.
+     */
+    void addNamespaceToSOAPHeader(const AxisChar * pUri, const AxisChar * pPrefix);
+
+    /**
+     * Clears SOAP header namespaces.
+     */
+    void clearSOAPHeaderNamespaces();
+
+    /**
+     * Add attribute to SOAP header.
+     *
+     * @param pLocalname The local name of the Attribute.
+     * @param pPrefix The prefix of the Attribute.
+     * @param pValue The value of the Attribute.
+     */
+    void addAttributeToSOAPHeader(const AxisChar * pLocalname,
+                                  const AxisChar * pPrefix,
+                                  const AxisChar * pValue);
+
+    /**
+     * Clears SOAP header attributes.
+     */
+    void clearSOAPHeaderAttributes();
+
+    /**
+     * Add namespace to SOAP body.
+     *
+     * @param pUri The namespace uri .
+     * @param pPrefix The prefix to associate with the uri.
+     */
+    void addNamespaceToSOAPBody(const AxisChar * pUri, const AxisChar * pPrefix);
+
+    /**
+     * Clears SOAP body namespaces.
+     */
+    void clearSOAPBodyNamespaces();
+
+    /**
+     * Add attribute to SOAP body.
+     *
+     * @param pLocalname The local name of the Attribute.
+     * @param pPrefix The prefix of the Attribute.
+     * @param pUri The namespace uri of the Attribute.
+     * @param pValue The value of the Attribute.
+     */
+    void addAttributeToSOAPBody(const AxisChar * pLocalname,
+                                const AxisChar * pPrefix,
+                                const AxisChar * pValue);
+
+    /**
+     * Clears SOAP body attributes.
+     */
+    void clearSOAPBodyAttributes();
+
   /**
     * Set proxy server and port for transport.
     *
@@ -641,6 +701,12 @@ class STORAGE_CLASS_INFO Stub
     */
     vector <IHeaderBlock *>::iterator m_viCurrentSOAPHeaderBlock;
 
+    std::vector < IAttribute * >m_vSOAPHeaderNamespaces;
+    std::vector < IAttribute * >m_vSOAPHeaderAttributes;
+
+    std::vector < IAttribute * >m_vSOAPBodyNamespaces;
+    std::vector < IAttribute * >m_vSOAPBodyAttributes;
+
 #ifdef WIN32
     #pragma warning (pop) 
 #endif

Modified: axis/axis1/c/trunk/src/cbindings/client/StubC.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/cbindings/client/StubC.cpp?rev=1234275&r1=1234274&r2=1234275&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/cbindings/client/StubC.cpp (original)
+++ axis/axis1/c/trunk/src/cbindings/client/StubC.cpp Sat Jan 21 06:38:40 2012
@@ -897,6 +897,172 @@ void axiscStubSetTransportAutoRedirect(A
     }
 }
 
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddNamespaceToSOAPHeader(AXISCHANDLE stub,
+        const AxisChar *pachNamespaceURI, const AxisChar* pachPrefix)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->addNamespaceToSOAPHeader(pachNamespaceURI, pachPrefix);
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPHeaderNamespaces(AXISCHANDLE stub)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->clearSOAPHeaderNamespaces();
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddAttributeToSOAPHeader(AXISCHANDLE stub,
+        const AxisChar *pLocalname, const AxisChar *pPrefix, const AxisChar *pValue)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->addAttributeToSOAPHeader(pLocalname, pPrefix, pValue);
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPHeaderAttributes(AXISCHANDLE stub)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->clearSOAPHeaderAttributes();
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddNamespaceToSOAPBody(AXISCHANDLE stub,
+        const AxisChar *pachNamespaceURI, const AxisChar* pachPrefix)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->addNamespaceToSOAPBody(pachNamespaceURI, pachPrefix);
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPBodyNamespaces(AXISCHANDLE stub)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->clearSOAPBodyNamespaces();
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubAddAttributeToSOAPBody(AXISCHANDLE stub,
+        const AxisChar *pLocalname, const AxisChar *pPrefix, const AxisChar *pValue)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->addAttributeToSOAPBody(pLocalname, pPrefix, pValue);
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
+
+
+AXISC_STORAGE_CLASS_INFO
+void axiscStubClearSOAPBodyAttributes(AXISCHANDLE stub)
+{
+    StubC *s = (StubC*)stub;
+
+    try
+    {
+        s->clearSOAPBodyAttributes();
+    }
+    catch ( AxisException& e  )
+    {
+
+        processException(s, e.getExceptionCode(), e.what());
+    }
+    catch ( ... )
+    {
+        processException(s, -1, "Unrecognized exception thrown.");
+    }
+}
 }
 
 

Modified: axis/axis1/c/trunk/src/engine/client/Stub.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/engine/client/Stub.cpp?rev=1234275&r1=1234274&r2=1234275&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/engine/client/Stub.cpp (original)
+++ axis/axis1/c/trunk/src/engine/client/Stub.cpp Sat Jan 21 06:38:40 2012
@@ -26,19 +26,22 @@
 #include <axis/AxisWrapperAPI.hpp>
 #include <axis/UnknownElementException.hpp>
 #include <axis/client/Stub.hpp>
+#include <axis/IAttribute.hpp>
 
 #include "../../transport/SOAPTransport.h"
 #include "../../soap/SoapSerializer.h"
 #include "../../common/AxisUtils.h"
 #include "../../common/AxisConfig.h"
 #include "../../common/AxisGenException.h"
+#include "../../soap/Attribute.h"
 
 #include "../../common/AxisTrace.h"
 
 extern AXIS_CPP_NAMESPACE_PREFIX AxisConfig* g_pConfig;
 
 AXIS_CPP_NAMESPACE_USE
-    Stub::Stub (const char *pcEndPointUri, AXIS_PROTOCOL_TYPE eProtocol):
+
+Stub::Stub (const char *pcEndPointUri, AXIS_PROTOCOL_TYPE eProtocol):
 m_proxyUsername (NULL),
 m_proxyPassword (NULL), 
 m_pExceptionHandler(NULL)
@@ -322,12 +325,140 @@ Stub::setSOAPHeaders ()
 }
 
 void
+Stub::addNamespaceToSOAPHeader(const AxisChar * pUri, const AxisChar * pPrefix)
+{
+    std::list<Attribute*> attributeList;
+    Attribute * pAttribute = new Attribute( attributeList, "", pPrefix, pUri, "");
+
+    m_vSOAPHeaderNamespaces.push_back ((IAttribute *)pAttribute);
+}
+
+
+void
+Stub::clearSOAPHeaderNamespaces()
+{
+    unsigned int j = 0;
+    for (j = 0; j < m_vSOAPHeaderNamespaces.size (); j++)
+    {
+        delete m_vSOAPHeaderNamespaces[j];
+        m_vSOAPHeaderNamespaces[j] = NULL;
+    }
+    m_vSOAPHeaderNamespaces.clear();
+}
+
+
+void
+Stub::addAttributeToSOAPHeader(const AxisChar * pLocalname,
+                              const AxisChar * pPrefix,
+                              const AxisChar * pValue)
+{
+    std::list<Attribute*> attributeList;
+    Attribute * pAttribute = new Attribute( attributeList, pLocalname, pPrefix, pValue);
+
+    m_vSOAPHeaderAttributes.push_back ((IAttribute *)pAttribute);
+}
+
+
+void
+Stub::clearSOAPHeaderAttributes()
+{
+    unsigned int j = 0;
+    for (j = 0; j < m_vSOAPHeaderAttributes.size (); j++)
+    {
+        delete m_vSOAPHeaderAttributes[j];
+        m_vSOAPHeaderAttributes[j] = NULL;
+    }
+    m_vSOAPHeaderAttributes.clear();
+}
+
+
+void
+Stub::addNamespaceToSOAPBody(const AxisChar * pUri, const AxisChar * pPrefix)
+{
+    std::list<Attribute*> attributeList;
+    Attribute * pAttribute = new Attribute( attributeList, "", pPrefix, pUri, "");
+
+    m_vSOAPBodyNamespaces.push_back ((IAttribute *)pAttribute);
+}
+
+
+void
+Stub::clearSOAPBodyNamespaces()
+{
+    unsigned int j = 0;
+    for (j = 0; j < m_vSOAPBodyNamespaces.size (); j++)
+    {
+        delete m_vSOAPBodyNamespaces[j];
+        m_vSOAPBodyNamespaces[j] = NULL;
+    }
+    m_vSOAPBodyNamespaces.clear();
+}
+
+
+void
+Stub::addAttributeToSOAPBody(const AxisChar * pLocalname,
+                            const AxisChar * pPrefix,
+                            const AxisChar * pValue)
+{
+    std::list<Attribute*> attributeList;
+    Attribute * pAttribute = new Attribute( attributeList, pLocalname, pPrefix, pValue);
+
+    m_vSOAPBodyAttributes.push_back ((IAttribute *)pAttribute);
+}
+
+
+void
+Stub::clearSOAPBodyAttributes()
+{
+    unsigned int j = 0;
+    for (j = 0; j < m_vSOAPBodyAttributes.size (); j++)
+    {
+        delete m_vSOAPBodyAttributes[j];
+        m_vSOAPBodyAttributes[j] = NULL;
+    }
+    m_vSOAPBodyAttributes.clear();
+}
+
+
+void
 Stub::applyUserPreferences ()
 {
       logEntryEngine("Stub::applyUserPreferences")
 
     setSOAPHeaders ();
       
+    // Set SOAP body and SOAP header attributes
+    SoapSerializer *pSerializer = NULL;
+    if (m_pCall)
+        pSerializer = m_pCall->getSOAPSerializer ();
+
+    if (pSerializer)
+    {
+        unsigned int i;
+
+        // add user-specified namespaces to SOAP header
+        for (i = 0; i < m_vSOAPHeaderNamespaces.size (); i++)
+            pSerializer->addNamespaceToSOAPHeader(m_vSOAPHeaderNamespaces[i]->getURI(),
+                                                  m_vSOAPHeaderNamespaces[i]->getPrefix());
+
+        // Add user-specified attributes to SOAP header
+        for (i = 0; i < m_vSOAPHeaderAttributes.size (); i++)
+            pSerializer->addAttributeToSOAPHeader(m_vSOAPHeaderAttributes[i]->getLocalName(),
+                                                  m_vSOAPHeaderAttributes[i]->getPrefix(),
+                                                  m_vSOAPHeaderAttributes[i]->getValue());
+
+        // add user-specified namespaces to SOAP body
+        for (i = 0; i < m_vSOAPBodyNamespaces.size (); i++)
+            pSerializer->addNamespaceToSOAPBody(m_vSOAPBodyNamespaces[i]->getURI(),
+                                                m_vSOAPBodyNamespaces[i]->getPrefix());
+
+        // Add user-specified attributes to SOAP body
+        for (i = 0; i < m_vSOAPBodyAttributes.size (); i++)
+            pSerializer->addAttributeToSOAPBody(m_vSOAPBodyAttributes[i]->getLocalName(),
+                                                m_vSOAPBodyAttributes[i]->getPrefix(),
+                                                m_vSOAPBodyAttributes[i]->getValue());
+    }
+
     logExit()
 }
 



Mime
View raw message