I'd like to repost a message that I found in this group almost one year
ago, because it's the exact problem I'm in and there was no solution
offered to this post last year. (note: I was not the original author
of the below post)
I have similar issue sharing types between the web services, and also
the
client consuming those web services. I have all my custom types defined
in a
seperate assembly and I am using those types as parameter/ return
values in
web methods. I am refering to those custom types in .asmx files using a
using
directive for that assembly(name space). But when the proxy is
generated when
added a web reference(or WSDL tool), those types r geting redefined in
the
proxy classes with their own namespace.
If I remove those defenitions manually and put a using directive at the
top
before the class definiton, there is no incompatibility issue between
the
types. But I need to happen this manually(specifying using directive
for the
assembly containing custom types, instead of REDEFNING them) as I have
several such web services and this manual process is getting even worse
whenever there r any updates to those web service's implementation.
Any ideas how to solve this will be greatly appreciated.
Gianluca Torta - 21 Jan 2006 10:52 GMT
I have the same problem and I think this is a very common issue.
Unfortunately the only two solutions I have heard about are:
(1) modify the proxy manually after it has been generated by WSDL (that
is the solution used by gbanister)
(2) in your client use the common types, then when communicating
from/to the Web Service convert them to the (identical) types defined
in the Web Service.
To do this it is not possible to just make a cast (CType in VB.NET)
because the two types even if identical appear as unrelated to .NET.
You have to serialize the object of type T1 into a stream, then
deserialize it as type T2 (there is a little function doing this at
http://weblogs.asp.net/cweyer/archive/2003/07/07/9768.aspx).
Currently I'm using (2) in my current project but clearly both (1) and
(2) are unsatisfactory solutions.
Anyone knows whether there are better solutions pheraphs in the final
release of .NET 2.0 (I am still using the Beta2) or in an upcoming
release of .NET?
gbanister - 22 Jan 2006 00:35 GMT
Thanks Gianluca!
I wonder if Indigo (WCF) has a better soution for this. I'd also
consider the best solution for sending custom types over the wire to
include binary serialization so that it will serialize private members
of a custom type as well.