开发者

Advantages of multiple endpoints in WCF service

I am new to WCF. Ple开发者_如何学Goase tell me what is advantage of creating multiple endpoints to a wcf web service?

Also can you please help me with an example that how to host such service in IIS and how a wcf client will connect to exact endpoint provided.

Thanks.


The advantage of providing different endpoints is that each endpoint could use different binding. This way based on the client capabilities he could choose the appropriate binding. For example you could expose an interoperable endpoint for Java, PHP, ... clients and a proprietary binary endpoint which could be faster but only for .NET clients.

Each endpoint has address, binding and contract. So the client could choose which service endpoint he wants to consume.

To host a WCF service in IIS you have 2 possibilities: either in an ASP.NET application where only HTTP bindings are available (basicHttpBinding, wsHttpBinding, webHttpBinding, ...) or in WAS (IIS 7.0 only) where you can use binary bindings. From a client perspective you add a Service Reference to the client project pointing to a given service url and consume the service. And here's another article you which discusses this.


From experience:

  • Using different binding, for example one BasicHttpBinding for Java clients while using WsHttpBinding for .NET clients. Also HTTPS for some and HTTP for others...

  • Dividing and exposing different contracts/interfaces. For example you have one interface that exposes many operations and you have a cut down interface which does basic things and you publish the second to outside so internal clients use the endpoint for extended interface but external clients use the other one.

For example

interface IFoo
{
   void DoBasic();  
}

interface IFooInternal : IFoo
{
   void DoMore();  
}

Now you have One class implementing both:

public class Foo : IFooInternal 
{
    ....
}

And now you expose only one to outside while implementation is in the same class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜