what is the use of multiple endpoints in WCF service? - wcf

i have seen people decorate their config file with multiple endpoints in WCF service. is there any reason. when one endpoint is ok then why two or more endpoints are require?
tell me small situation when multiple endpoints is required.

Scenario for multiple endpoints:
Service wants to expose more than one type of binding.
Service wants to expose more than one contract on the same binding.
Service wants to expose same binding and contract on different addresses.
http://debugmode.net/2010/05/25/multipleendpoint/

Related

How can I use all endpoints with service reference In WCF?

I write my service with multiple binding.And I use 2 baseadress and I create 3 end points for tcp and 3 end points for http.How can I use all endpoints with service reference in client app?Is it enough to add base adress to service reference?
Assuming that you have only one service which exposes three contracts, then you would have to have for each contract an defined endpoint. In your case, because you are using two bindings basicHttp and tcp you will have three for each binding type. I don't see the point of referencing the endpoints for both bindings in your client application. Is this a API library or something? If that is the case I recommend you to use the channel factory in order to build your client proxies manually, svcutil.exe will cause you trouble in this scenario.

Define Endpoints for each web service and contract in wcf

I have WCf application with4 webserivce with indivdual Interface as contract. so do i need to define endpoint, serviceBehaviors for each web service in config file? to access individual web service in single or multiple web applications?
Each Webservice can be exposed using one (i.e. one endpoint for all webservices) or multiple endpoints (i.e. one for each webservice). Each endpoint will have behavior,binding etc
If you go with 1st option client will have one proxy-contract for an endpoint.
In your case you can expose all four service interface using single endpoint.
Each service must have a corresponding address, endpoint and binding definition. If you are using config files each service must be declared in a separate <service> node in the <services> collection.

All about wcf client

When I deploy the same service on different machines as they have different information that I need , how can I use my client gracely to consume these service .
You need to define the service endpoint you want to connect to in your client's config.
You cannot define a list of endpoints - if you need load-balancing features, you need to implement those on the server side and "hide" them behind a single service endpoint.
With .NET 4 and WCF 4, you have new capabilities you could check out:
WCF 4 has a new routing service which you can use to get called on a single URL, and you have control over how to "distribute" those calls to the actual back-end servers
WCF 4 also supports dynamic service discovery, so you could potentially just "yell out onto the network" and get back one service endpoint address that supports your contract you're interested in
Resources:
Developer's Introduction to WCF 4
10-4 Show on WCF 4 Routing Service
Content-based routing with WCF 4
WCF 4.0 Routing Service
WCF 4.0 Routing Service - Failover
Using WS-Discovery in WCF 4.0
Ad-hoc Discovery with Probing messages
It sounds like you want to connect to BOTH servers. you say they have different data that you need. Well, if you already know how to make a client to one of them, the easiest way is to define an entire other client to access the second one. You can define as many clients as you want in the config file. Then just call them both in code.

WCF Callback Service hosted over basicHttpBinding and wsDualHttpBinding

I have a callback service that is hosted over wsDualHttpBinding. I'm looking to add a client that will poll for the data rather than receive the callback (will be a mobile device using wince for demo purposes). I was curious what the best way to do this is? You cannot create a client proxy using NetCFSvcUtil with a service hosted with wsDualHttpBinding (I understand that), but you cannot host a callback service over basicHttpBinding. I really need the same service hosted over both basicaHttpBinding (clients will poll for data) and wsDualHttpBinding (callback will notify clients of data). Any ideas on the best way to handle this without creating two separate services to host the same data?
What do you mean by two separate services hosting the same data? Do you expect to share same service instance to handle both wsDualHttpBinding and basicHttpBinding requests?
Your current problem is that service interface for duplex communication cannot be used for basicHttpBinding. You have to create second service contract and implement it in the same service. In that case you can expose two endpoints for the service: one duplex with WSDualHttpBinding and one with BasicHttpBinding. Endpoints must have different relative addresses. From the perspective of the client those endpoints are separate services - each of them requires separate client proxy. So unless your service is singleton you will have new service instance for each client proxy. New service instance means no data sharing.
Thera are some possibilities to modify this behavior but it means replacing Instance provider.

WCF callback contracts and server to server

I am developing a solution with multiple WCF services which all communicate among themselves, even though they are of different types. The services connect to one another through the ChannelFactory generic interface, and every service is hosted inside a ServiceHost.
My question is if it would be correct to use a callback contract among the servers to communicate with one another and if so how would such a solution look.
Currently I don't like the implementation because every service needs to host a couple of endpoints with different interfaces some for other services and some for other clients.
When I tried to implement the callback contract inside a service class that was hosted inside a ServiceHost it failed.
First of all, whenever you post a question saying, "it failed", you need to tell us in what way it failed. If there was an exception, then you need to post the entire exception, including all InnerException instances, by posting the result of ex.ToString().
To your problem, I'd implement a service contract that represents the part of each service that needs to talk to the other services. There would also be a callback contract associated with this service contract.
That way, it's as though each service operates a miniature service intended only for service-to-service communications. They can then each do their own thing with the information that is passed between the services.