New Feature: Barebone SOAP Functionality

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply

Do I Need SOAP In My Project?

Yes
4
27%
No
11
73%
 
Total votes: 15

dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

New Feature: Barebone SOAP Functionality

Post by dlangdev »

Hi all,

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
Step #2: Test it using this code fragment shown below...

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 ...

By the way, this is not production ready code. You'd be a fool to think it is prod quality.

You will need to study the code and adjust it according to your environment, only then you can apply it to your prod.
Last edited by dlangdev on Tue Feb 19, 2008 10:43 pm, edited 1 time in total.
Image
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

what is soap :roll: (you missed that one on the poll:P).
ecsos
Posts: 30
Joined: Mon Feb 04, 2008 8:02 am

Post by ecsos »

this is actually pretty cool.
you could could do a lot of theoretically cool stuff with this
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

it's not complete, though. it needs to be connected to an xml/xlt library in order for the elements to be extracted.

with that code alone, a lot of interesting things can be made with it. i guess you already seen the beauty and power of its potential.
Image
jingquan
Posts: 222
Joined: Sun Aug 20, 2006 4:10 am
Contact:

Post by jingquan »

Vsk wrote:what is soap :roll: (you missed that one on the poll:P).
I'll like to know too.
Anteater
Posts: 266
Joined: Thu Jun 01, 2006 4:02 pm
Location: Earth
Contact:

Post by Anteater »

Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Anteater wrote:Wikipedia is your friend. :D
No is not! :P. We are fight for so long. :).
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Yeah... I can see some uses for it. The main strength being to get around firewalls (as it acts through the HTTP transport) and have a sort of structure to your messages (XML).

For highspeed twitch games, it is impractical for wasting way too much bandwidth on the XML overhead and extra work to reconstruct the data/break down the XML.

However, if you have something with less messages, less often and easier to understand, that is where SOAP starts usefulness. The other perk is that you can set your WSDL to return formatting info and with that, other apps can then easilly interface with your server. Since SOAP is also cross-platform with lots of implementations, your "Server" could be Apache-PHP, Rails, Grails, etc.
Crud, how do I do this again?
plotti
Posts: 21
Joined: Thu Oct 18, 2007 9:58 am

Post by plotti »

SOAP is a nice idea.

Although I think that SIP is much more promising and better suited for this aspect, actually right now i am experimenting with the SIP protocoll and missusing a SIP Voip Stack to provide a network layer for Irrlicht.

Main benefits are:
Simplicity
P2P functionlity
NAT traversal
RTP for time critic apps
and REGISTRAR and PROXY functionalities for easy setup and location.

--> from my point of view this will be the the protocoll to use in the future online gaming.

+ of course if you use SIP , voip comes for free, just like that.
________
MEXICO CITY HOTEL
Last edited by plotti on Tue Feb 22, 2011 8:13 am, edited 1 time in total.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Why would I want to use SIP instead of SOAP?

<Scratches Head>

Just because SIP can stream sound does not mean it can handle SOAP.

<Scratches Head Again>

<Looks up to the big blue sky>
Image
plotti
Posts: 21
Joined: Thu Oct 18, 2007 9:58 am

Post by plotti »

well true comparing soap with sip is like apples and bananas.

is there any application scenario soap could be used in though?

Displaying weather information in the game??
________
CL360
Last edited by plotti on Tue Feb 22, 2011 8:14 am, edited 1 time in total.
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Actual, my team is now using this SOAP implementation as a starter framework for our game, which is a boardgame. Basically, using the SOAP interface seemed fine as we aren't concerned with bandwidth or twitchyness or the need for clients to poll.

Being able to send a SOAP pattern out with a bundle of commands made sense. Yeah, we could streamline it and generate our own packet formats for pure speed, but meh... XML just works for this.

I've actually started coding the server in Rails. This is going to be an interesting project.
Crud, how do I do this again?
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Double post.
Last edited by dlangdev on Tue Feb 19, 2008 10:59 pm, edited 1 time in total.
Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Dear Saigumi:

This is very interesting, I'd like to work with you sometime in the future when you have implemented a working SOAP demo. I have already a sample implementation working, though I can't release it due to personal reasons.

It would be nice to setup a collaborative effort in setting-up a common architecture for SOAP-based applications running on 3D engines like Irrlicht.

If you're interested in writing up a standard for servers and clients running on SOAP, please let me know. We'll put it up on a domain and market it for public and corporate adoption.

I've implemented my sample SOAP demo using MS DotNet, SQL Server, Webservices. And they work pretty well with a remote Irrlicht client. These set of tools could become a standard if we write them up, though. Then market it later.
Image
Post Reply