开发者

Wcf different clients different methods same interface

I have a service with tcpbinding.I have an interface with 20 methods.I have got different types of clients.one of them can access 10 methods of these 20 and I have got another client who can access all the 20 methods and another who can access only 15.so how can i achieve this??how can I go for authentication for operation contract?whi开发者_运维知识库ch attribute?Is there any other way to achieve this?can you please specify in how many ways we can achieve this?


You can expose any service and all of its methods over any kind of protocol binding you like.

You cannot however expose only some of your methods - e.g. you will not be able to have a single service contract with 20 methods, and then expose only 10 of those to a certain set of clients.

Basically, you need to create one service interface for each set of methods you want to expose.

What you can then do is have a service class implement the first 10 methods and expose that service to all those clients who can access those 10 methods.

You could then have a second service interface with another 5 methods, and have a second service implementation class that implements the first and the second interface for the total of 15 methods - and expose that service over some bindings to another set of clients - and so on ....


Today i've faced the same problem and it is really simply to achieve. Basically you have N different interfaces with N different .svc files. The main code is in the interface/svc that has ALL functions. In the other interfaces/svc files you have to declare the methods and as implementation you can simply declare the main object and then call its methods. For example:

Main Interface/SVC - IMainInterface - Main.svc

class MainSVC
{
    public void functionA()
    {
        //code
    }

    public void functionB()
    {
        //code
    }
}

In the other interfaces declare only what you need: Customer Interface/SVC - ICustomer - Customer.svc

class MainSVC
{
    public void functionA()
    {
        Main main = new Main();
        main.functionA();
    }
}

Of course your customer must use Customer.svc and not Main.svc otherwise he can use all methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜