Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Multiple Endpoints and IServices

I am just trying to get to grips with using WCF, and I am wandering if someone could tell me if I have the right idea with endpoints.

I have been working through the videos on msdn, and now I am wandering about the way to configure WCF Service. The scenario is if I have multiple IServices, e.g. such that I have an IThis and IThat, and the client needs the access both (note: they will be using net.tcp),

  • IThis handles database querying and,

  • IThat handles calculations independent of the database,

I assume that I have to define separate Endpoints for IThis and IThat, that are referenced in the client separately. Or would I create an overall IThisAndThat Service that gets referenced in the client and contains the functionality for both??

Or is are the other ways for developing and handling WCF Services with multiple IServices? While I'm asking can you define base address for tcp or only http?

~Thanks all, any help or pointers would be great.

like image 848
Heinrich Avatar asked May 30 '11 02:05

Heinrich


People also ask

Can WCF service have multiple endpoints?

As demonstrated in the Multiple Endpoints sample, a service can host multiple endpoints, each with different addresses and possibly also different bindings. This sample shows that it is possible to host multiple endpoints at the same address.

How does WCF define multiple endpoints?

The first endpoint is defined at the base address using a basicHttpBinding binding, which does not have security enabled. The second endpoint is defined at {baseaddress}/secure using a wsHttpBinding binding, which is secure by default, using WS-Security with Windows authentication.

How many endpoints can a WCF Service have?

They should see only one endpoints and also when we are write service it will have multiple methods I want certain methods to be in wsdl.

Can a service have multiple endpoints?

A service may have multiple endpoints within a single host, but every endpoint must have a unique combination of address, binding and contract.


1 Answers

I assume that I have to define separate Endpoints for IThis and IThat, that are referenced in the client separately. Or would I create an overall IThisAndThat Service that gets referenced in the client and contains the functionality for both??

You can do both:

  • you can create a separate service implementation class - one for IThis, another one for IThat
  • or you can create a single service implememtation class that implements both IThis and IThat

That choice is entirely up to you.

For every service implementation class that you have, you can define any number of endpoints you wish to have. So if you have an ThisService implementing IThis, you can define a HTTP and a TCP endpoint for that, and you also have a ThatService that implements IThat for which you define a TCP endpoint. That's totally up to you.

BUT: you can only define your endpoints for each service implementation class - if you have a ThisAndThatService implementing both service contracts, you cannot define 3 endpoints for IThis and two different ones for IThat - the endpoints you define are per service implementation class.

While I'm asking can you define base address for tcp or only http?

Yes, absolutely - you can define a base address for each of the various addressing schemes (http, net.tcp, net.msmq, net.pipe and so forth).

like image 193
marc_s Avatar answered Oct 11 '22 19:10

marc_s