Click here to Skip to main content
16,019,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends

Could you please guide me through how I can expose the mulitple contracts in a single service.

I am having the follwoing Contract in my service Layer.
ISiteService
IOrderService
IProductService...

I want the follwoing things to be done.

1) how I host the Service using the TCPBinding exposing the all service contracts for the client application.
2) how I can invoke the service contract at client end.


I have gone through the many examples but they only explain the one service contract.

Thanks
Posted
Updated 15-Jun-10 1:38am
v2

You should create an EndPoint for each WCF interface you want to expose.If you using the code, it should be something like this:
ServiceHost host=new ServiceHost(typeof(YourServiceClass));
host.AddEndPoint(typeof(Interface1),...);
host.AddEndPoint(typeof(Interface2),...);
host.AddEndPoint(typeof(Interface3),...);
host.Open();
If you are using the config file, add corresponding sections to it.
If you use this approach YourServiceClass should implement all three interfaces.
On the client side you should use a proxy for each interface. Use SvcUtil to create the proxies(you may use VS features as well).
good luck
 
Share this answer
 
I do not have any link or some code handy. Although I would say this a same as having multiple aspx pages in one web application.

Have a WCF application project. Add n number of services to it. Host it in IIS or whatever you use and I would work. Almost same as any ASP.Net application with multiple aspx pages.
 
Share this answer
 
You can have one WCF application with multiple svc files. Each would refer to a different service. So once you have hosted it, you would have three endpoints for the three services. Your client can either add a service reference using the URL or create a service proxy to call the method.
 
Share this answer
 
Comments
rajeshswami27 15-Jun-10 8:25am    
Thanks D@nish,

I always appreciate for you immediate response.

Could you please direct me to some resource links

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900