google-code-export / staff

Automatically exported from code.google.com/p/staff
Apache License 2.0
1 stars 1 forks source link

How can i add more than one NameSpace in SOAP? #107

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
How can i create a xml which have more than one namespace like this.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="http://www.google.com/edp/xmlservice/" 
xmlns:ns2="http://www.google.com/Interceptor/">
<soapenv:Body>

Actually auto generated proxy have a code like this, here i can able to add 
only one namespace uri for my soap.

void XMLServiceProxy::Init(const std::string& sServiceUri, const std::string& 
sSessionId, const std::string& sInstanceId)
{
  staff::IService::Init("XMLService", sSessionId, sInstanceId);
  m_tClient.Init(!sServiceUri.empty() ? sServiceUri : "http://172.16.234.197:8080/EDPService/xmlservice");
  staff::COptions& rOptions = m_tClient.GetOptions();
  rOptions.SetDefaultNamespace("http://www.mastek.com/edp/xmlservice/", "");

  rOptions.SetSessionId(sSessionId);

  if (!sInstanceId.empty())
  {
    staff::COperation tOperation("CreateInstance");
    tOperation.Request().CreateChild("sInstanceId").SetText(sInstanceId);
    tOperation.SetResponse(m_tClient.Invoke(tOperation.Request()));
    if (m_tClient.GetLastResponseHasFault())
    {
//      RISE_ASSERTES(!tOperation.IsFault(), staff::CRemoteException, 
tOperation.GetFaultString()); // soap fault
 //    RISE_THROW3(staff::CRemoteException, "Failed to invoke service", tOperation.GetResponse().ToString()); // other fault
    }
    rOptions.SetInstanceId(sInstanceId);
  }
}

Original issue reported on code.google.com by boobal...@gmail.com on 6 Jun 2011 at 11:51

GoogleCodeExporter commented 9 years ago
Please don't use issues list to ask a question. To ask a question please use 
SupportPage .

I not sure that you can add additional namespaces into SOAP Envelope tag 
because SOAP Envelope is created inside Axis2/C axis2_svc_client_send_receive 
function.

But even if you do that, you should manage your additional namespaces manually.

To see an example how to create custom client, please see:
staff/samples/echo/custom_client_blocking/src/main.cpp

To add additional namespace into the payload, you can write something like this:

tdoPayload.DeclareNamespace(staff::CNamespace("ns2", 
"http://www.google.com/Interceptor/"));

don't forget to include staff/common/Namespace.h

Original comment by loentar on 6 Jun 2011 at 2:09