Say I have the following interface that I want to share between my server (a regular web service) and my client (a silverlight 2.0 application):
public interface ICustomerService
{
Customer GetCustomer(string name);
}
My web service implements this interface, and references a class library where Customer
type is defined.
Usually, if you want to consume this service from a WCF client, say a winforms app, you could share your model assembly and your service contract interfaces. Then, by using a ChannelFactory
, you can dynamically create a proxy which implements your service interface. Something like:
ICustomerService myService = new ChannelFactory<ICustomerService>(myBinding, myEndpoint);
Customer customer = myService.GetCustomer("romain");
I basically want to do the same thing, but from a Silverlight 2.0 application. The silverlight ChannelFactory
doesn't seems to act like the other one...
Do you know if it's possible ?
Note : Since a Silverlight application can only refers Silverlight projects, I have:
Two versions of MyModel.dll which contains Customer
type:
- One compiled targetting .NET framework 3.5, referenced by my web service project
- Another compiled targetting the silverlight 2.0 framework, referenced by my silverlight app
Two versions of MyServicesContracts.dll which contains ICustomerService
interface:
- One compiled targetting .NET framework 3.5, referenced by my web service project
- Another compiled targetting the silverlight 2.0 framework, referenced by my silverlight app