Using Soap Client Library for C++ to Access IBM Message Broker Message Flow via SoapInput Node

SQLData offers a SOAP client library which allows you to access web services using  C/C++ code.  With a few lines of code you can easily access a web service exposed from a SoapInput Node on Websphere Message Broker.

Here is a short example, the trick is to store the parameters you wish to pass to the Web Service Method in two arrays, the first array in this instance pParams stores the parameter names as they appear in the WSDL e.g. partNo etc, note that parameters which have a nested structure within the WSDL, they must appear similar e.g. address.zipCode.  In the second array you store the values. Place a NULL at the end of each array.

Here goes, compiled with Visual Studio 2008, Soap Client Library for C++ 3.6, IBM Message Broker 7.0, Message Broker Toolkit 7.0 and MQ 7.1

#include <windows.h>
#include <tchar.h>
#include "SoapClientApi.h"
#include "exportdef.h"
#include "stringdef.h"


#define DEBUG_MODE_ON 1
#define DEBUG_MODE_OFF 0


int WMB_submitPO(int);


int main(int argc, char **argv)
{
WMB_submitPO(DEBUG_MODE_ON);
return 0;
}


int WMB_submitPO(int nDebugMode)
{
TCHAR *pParams[8]={TEXT("partNo"),
TEXT("partQuantity"),TEXT("personName.firstName"),
TEXT("personName.lastName"),TEXT("address.street"),
TEXT("address.city"),TEXT("address.zipCode"),
NULL};


TCHAR *pValues[8]={TEXT("1234"),
TEXT("10"),TEXT("Trevor"),
TEXT("O Connell"),TEXT("Abbeydorney"),
TEXT("Tralee"),TEXT("N/A"),
NULL};


const TCHAR * szResponse = NULL;
SoapAgent *pSoapAgent;

pSoapAgent= MakeSoapAgent(NULL, NULL,4);


if(pSoapAgent==NULL)
return -1;


vector<tstring>* pOutputValues;

HRESULT hr;


if(SUCCEEDED(hr=pSoapAgent->ExecuteMethod(
TEXT("service.wsdl"), // WSDL file
TEXT("submitPO"), // method name to be invoked.
pParams, // vector of input parameter names.
pValues, // vector of input parameter values.
&pOutputValues // pointer to vector of output parameters
)))
{
_tprintf("\nWeb Service Call Success");
szResponse = pSoapAgent->GetResponse(NULL, true);
_tprintf("\nComplete Reponse : \n%s\n", szResponse);
}
else
{
_tprintf("\nWeb Service Call Failure");
}


DestroySoapAgent(pSoapAgent);


return 0;
}

Comments

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Creating a simple Alert / Success Message with ASP.NET/VB using Bootstrap