I want to use typed parameters in the web methods. But when visual studio 2005 creates the web reference on for the client it automatically creates it's own types. I am using a .net web service and a .net client.
For example:
< WebMethod > _ Public Function Foo() as ServerNamespace.Bar ... End Function
at the client the method becomes WebServiceInstance.Foo() as ClientNamespace.Webservice.Bar
returning a different type.
I started writing my own serialization helper class to convert the type, but I would have thought there would be a better way....
There is also a good answer here: .NET SOAP Common types
Basically you are not supposed to share the data structures between the server and the client. But if you really want to there seam to be possibilities.
If you can upgrade to .Net 3.0, I would suggest switching to WCF for your client proxy. Svcutil.exe is the tool to generate a WCF client proxy from the web service; it has an option /reference, which takes an assembly and reuses any shared types from it. (I would also suggest switchnig the service to WCF if it's under your control :-))
If you can't upgrade, wsdl.exe has an option /sharetypes which might help you, although I am not sure how to do it exactly.
I've asked the same question before, so the answers I got might be of help:
Force .NET webservice to use local object class, not proxy class
I have upgraded to VS 2008, and WCF. I still find the solution to be half baked. Shared types seem to work ok as long as they are not typed collections, which get converted to and array or List(Of T).
I really don't understand what is so hard about serializing to and from the same object type, collection or otherwise.
A number of people reference this article from Code Project (article)
Which works for some objects, but for my data objects generates the following warnings (if I force it to use the DataContractSerializer):
I could not find anything meaningful that would help me to debug this.