Hello everyone!
I have been looking for information regarding the SOA tenet of
decoupling the client interface from the web service interface. I
understand the value of not sharing a contract based on a class type;
instead, a contract based on the data is what we should be
implementing. However, information on how to properly implement this
in .NET 2.0 is pretty scarce.
I have been fiddling around with a simple web-service and client I
created just to test this idea. On the web-service side I have a
simple HelloWorld method that returns a new instance of the following
type :
public class WebService.Test
{
// data I would like to include in the contract
public string FirstName = "Hello";
public string LastName = "World";
// other data and methods I do not want in the contract
...
}
As you can see from the above comments the only data that needs to be
passed to the client are the FirstName and LastName fields; I do not
want the other data and methods to be passed/implemented on the client
side.
On the client side, I have the following Test class defined (very
simple and short for brevity) :
public class Client.Test
{
private string FirstName;
private string LastName;
public override string ToString()
{
return FirstName + " " + LastName;
}
}
As you already know, I can't cast the result of the web-method call to
the client-side version of Test. So the million dollar question is :
what is the best way to accomplish this?
On the client side I can update the web-reference and generate two
files : Reference.cs and Test.datasource. The Reference.cs file
contains the definition for the Test class which includes metadata for
the other data and methods that I do not want. I can, of course,
simply trim this automagically created Test class down to size (just
keep the FirstName and LastName fields) and implement whatever client-
side logic I want but it seems that every time you update the web-
reference you have to re-implement the code all over again since it
gets overwritten.
Would anyone point me in the right direction, maybe a few links or
excellent books? There must be a design pattern for this. I notice
that there's a DataContract attribute in .NET 3.0 but I'm limited to
the .NET 2.0 framework for now.
Regards,
Anthony