I'm releasing the code that will provide barebone Win32 SOAP functionality to your irrlicht application.
This will apply only to those projects who like to leverage their SOAP services onto their Irrlict games. Grab a copy and test it in your environment.
Step #1: Copy the code below and paste it in ISoap.h
Code: Select all
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_SOAP_H_INCLUDED__
#define __IRR_SOAP_H_INCLUDED__
// ISoap.h
#include <stdio.h>
#import "msxml3.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib;
#pragma message("ISoap is included")
namespace irr
{
namespace core
{
class ISoap
{
public:
virtual void set_wsdl( const wchar_t* url) {
wsdlUrl = url;
}
virtual void set_soapActionUrl( const wchar_t* actionUrl) {
soapActionUrl = actionUrl;
}
virtual void set_body( const wchar_t* xmlBody) {
soapXmlBody = xmlBody;
}
virtual void send() {
// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"] = wsdlUrl;
Connector->Connect();
// Begin message
Connector->Property["SoapAction"] = soapActionUrl;
Connector->BeginMessage();
// Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer));
// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
// Build the SOAP Message
Serializer->startEnvelope("","","");
Serializer->startBody("");
Serializer->writeXML( soapXmlBody );
Serializer->endBody();
Serializer->endEnvelope();
// Send the message to the web service
Connector->EndMessage();
// Let us read the response
Reader.CreateInstance(__uuidof(SoapReader));
// Connect the reader to the output stream of the connector
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
//printf("Webservice Reply ==> %s\n", (const char *)Reader->RPCResult->xml);
xmlResult = strdup( ( const char* )Reader->RPCResult->xml );
//printf("output %s\n\n", xmlResult);
}
virtual const char* result() {
return ( xmlResult ) ;
}
private:
const wchar_t* wsdlUrl;
const wchar_t* soapActionUrl;
const wchar_t* soapXmlBody;
const char* xmlResult;
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
};
} // end namespace core
} // end namespace irr
#endif
Code: Select all
... more code here ...
#include <ISoap.h>
... more code here ...
CoInitialize(NULL);
core::ISoap ws1;
core::stringw wsdl(L"http://www.mydomain.com/soap/admin.asmx?wsdl");
core::stringw actionUrl(L"http://www.mydomain.com/soap/getStudentInfo");
core::stringw soapBody(L"<getUserInfo xmlns='http://www.mydomain.com/soap/ws'><userID>1595526</userID></getUserInfo>");
ws1.set_wsdl( wsdl.c_str() );
ws1.set_soapActionUrl( actionUrl.c_str() );
ws1.set_body( soapBody.c_str() );
ws1.send();
const char *ret1 = ws1.result();
core::stringw s1( ws1.result() );
if ( strlen(ret1) == 0 ) {
printf("No return value");
}
CoUninitialize();
... more code here ...
You will need to study the code and adjust it according to your environment, only then you can apply it to your prod.