R – Consuming a Web Service written in VS2008

web services

I've got a Web Service written using C# in Visual Studio 2008 (I've also written it in VS 2005).
I can write a test windows form app to consume the service no problem.

The problem I have is consuming it from C#/VS2003 (or php which is my real problem). It just gives me the error:

"Cannot implicitly convert type 'TestIntel.WebIntel.GetSitesResponseGetSitesResult' to 'System.Data.DataTable"

The Web mthod does return a DataTable; as I said this works fine if the consumer was built in VS2005/2008. What gives?

Best Answer

In order to consume a DataTable, the calling points (php and .net 1.1) need to know how to deserialize it into usable object.

This means that they would have to have a similiar object that the data can be deserialized into.

Obviously, PHP can't do that. And the reason for the .net 1.1 error is that the DataTable object changed quite a bit between 1.1 and 2.0. In fact, Microsoft says that the .Net 1.1 datatable object is BY DESIGN not supposed to be serialized through a web service. ( [http://support.microsoft.com/kb/306134][1] )

If you are looking for a real cross language way of doing this then you need to serialize your response into a standard XML object. Which could be parsed correctly by any language. This is a little more work, but results in a usable service.

Related Topic