Sunday, November 20, 2005

Consume a Web service using VB6 ... Long Life VB6

I was a VB6 developer, and it seems that I will remain for a while even that the major of my work is in C#.

A friend of mine has asked me how to consume a web service using VB6.

I have seen a sample before about using the SOAP Client installed in WinXP and above to call a web service.

Soap Client is a COM component, so it can be used easily in VB6.

So, I opened VS.net and write a simple web service that Add 2 numbers and return the result.

And, amazingly it is very easy to get this job done in VB6. Just a new object of SOAP Cleint and give it the WSDL URL.

Forget the intillesense and call the method and assign the result in a variable.

The problems are coming.

My friend asked: "Is it possible to return a record set from a web service?"
Hmmm …

Things have been tough, I added a new mrthod to the simple web service that return a DataSet. I have expected that SOAP Client will not be able to parse it and just the return may be a string with the XML serialization of the DataSet.

But; this was not right. I have tested the type of the result :

Debug.Print TypeName ( soapClient.GetEmployees )

And the result was of type IXMLDOMNodeList.

Waw !!!

Then we have an instance of an XML object thatwe can traverse its child nodes searching for the value(s) we are searching for.

This is a tough job.

Examining the XML representation of a DataSet, gives a bad feeling … What is the heck this is needed for , Why not just consume that web service using .net !!


It is doable, but is not funny …

3 comments:

Anonymous said...

gadéchék ta7an! ta7chi fih 3lina!

Anonymous said...

Ye7chi fih bil 9wiiiii

Anonymous said...

Banbilou el houlou houlou!