Al.
Al.

Reputation: 875

Expose different WSDL for different clients

I have developed a WCF application which is being consumed by three .NET web service clients. So far so good.

But now I should change the WCF application in such a way that a different schema is published to different clients.

For example:

class A : IMyServices
{
    public string GetName() {}

    public Order GetOrderInfo(string orderId) {}

    public Payment GetPaymentDetails(Order order) {}
}

One of my clients should not see GetPaymentDetails (I should basically hide this GetPaymentDetails and Payment class schema from the WSDL that is being created by that one client). Other clients will have restrictions on other methods.

In some scenarios some of the Payment class's properties should not be exposed to a client even it has access to the GetPaymentDetails operation.

Is there any way to expose different schemas for different clients and that requires minimum changes at my end?

One thing to keep in mind: my service is developed using WCF, and clients consuming my services use traditional .NET web service.

Upvotes: 1

Views: 415

Answers (1)

Jeroen
Jeroen

Reputation: 63709

How about splitting the interfaces and exposing different endpoints (possibly with different security) for the various contracts? You could design your contracts and implementation along these lines:

[ServiceContract]
public interface ICompleteService : IBasicService, IPaymentService
{ }

[ServiceContract]
public interface IBasicService
{
    string GetName();
    Order GetOrderInfo(string orderId);
}

[ServiceContract]
public interface IPaymentService
{
    Payment GetPaymentDetails(Order order);
}

class A : ICompleteService
{
    public string GetName() { }
    public Order GetOrderInfo(string orderId) { }

    public Payment GetPaymentDetails(Order order) { }
}

Then you can expose endpoints as you like, e.g. something like this:

  • IBasicService endpoint with minimum security
  • ICompleteService endpoint with maximum security

You could go along similar lines for the Payment DataContracts. The contracts are responsible for making sure the different endpoints get access to different operations and data, whereas under the hood they would share implementations, minimizing the amount of work you need to do to get this to work.

Upvotes: 1

Related Questions