Routing multiple wcf services to a single wcf
-
Monday, April 30, 2012 2:07 PM
Hi,
I have to services:
http://localhost/ChorusService/ProcessFirstEntity.svc with method Add
http://localhost/ChorusService/ProcessSecondEntity.svc with method Delete
Now I want to route these requests to another single service
http://localhost/ChorusService/ProcessThirdEntity.svc with a single method
ProcessAny. Please Help!!
- Edited by Priyank Kansal Monday, April 30, 2012 2:12 PM
All Replies
-
Tuesday, May 01, 2012 1:32 AMModeratorHello, in this case you can just add service reference to the ProcessThirdEntity in both ProcessFirstEntity and processSecondEntity, and invoke ProcessAny within the other two services' implementation.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email. -
Wednesday, May 02, 2012 5:27 AMNo, I am looking for the solution in WCF 4.0 Routing behaviour only.
.Net
-
Wednesday, May 02, 2012 6:16 AMModeratorDo you mean both ProcessFirstEntity.svc and ProcessSecondEntity.svc are routing services? In this case, you can just route everything to ProcessAnyEntity.svc (use a MatchAll filter). But the requirement is a bit strange. Why do you want to use two routing services to route to the same actual service?
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email. -
Wednesday, May 02, 2012 7:01 AM
Can I share my code with you?
.Net
-
Wednesday, May 02, 2012 7:13 AMModeratorYou can upload your project to SkyDrive to a public folder.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email. -
Wednesday, May 02, 2012 7:22 AMI didn't get you.
.Net
-
Wednesday, May 02, 2012 7:42 AMModeratorWell, you mentioned: "Can I share my code with you?". If you want to share your project, the best place is SkyDrive: http://skydrive.live.com/
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email. -
Wednesday, May 02, 2012 8:07 AM
Sorry Luo,
This site is not accessable here in my office. Is there having any other alternative?
Priyank
.Net
-
Wednesday, May 02, 2012 8:14 AMModeratorOK. You can also send an email to me directly: v-ylluo@microsoft.com. But I can't promise I'll definitely look into it.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email. -
Wednesday, May 02, 2012 9:31 AMModerator
I saw your email. When using built-in routing services, you cannot have custom service implementations. So you need to delete the .cs files for your routing service implementation. And modify both routing service's svc file to:
<%@ ServiceHost Language="C#" Debug="true" Service="System.ServiceModel.Routing.RoutingService,System.ServiceModel.Routing, version=4.0.0.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35" %>
This indicates you want to use WCF routing service, not your own service.
In addition, your routing service's web.config has the wrong address:
<client>
<endpoint address="http://localhost/TempReceiver/Receiver1.svc"
binding="basicHttpBinding" contract="*" name="ReceiverService1" />
</client>But the correct address in your case is: http://localhost:3727/ReceiverService/Receiver1.svc (port may vary).
Finally, you cannot add service reference to the routing services themselves. Routing services do not share the WSDL file with actual services. You have to add service references to the actual service. Then you can use code to construct two client proxies which point to the routing service:
RouterService1Client client1 = new RouterService1Client(new BasicHttpBinding(), new EndpointAddress("http://localhost:3725/RoutingService/RouterService1.svc"));
Item1 data1 = new Item1();
data1.Field_1 = "Hello Service1";
data1.Field_2 = "good morning Service1";string result1 = client1.GetData1(data1);
Console.WriteLine(result1);
RouterService1Client client2 = new RouterService1Client(new BasicHttpBinding(), new EndpointAddress("http://localhost:3725/RoutingService/RouterService2.svc"));
Item1 data2 = new Item1();
data2.Field_1 = "Hello Service1";
data2.Field_2 = "good morning Service1";string result2 = client1.GetData1(data2);
Console.WriteLine(result2);
The above code is sending requests to your routing services instead of the actual service. Since you only have a single actual service, you cannot have two different contracts. Routing service doesn't allow you to modify contracts. If you want to use contracts that do not exist in the actual service (say, Item2), you cannot use routing service. You have to build a normal WCF service without any routing features.
Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
If you have feedback about forum business, please contact msdnmg@microsoft.com. But please do not ask technical questions in the email.- Proposed As Answer by Yi-Lun LuoModerator Friday, May 04, 2012 9:29 AM
- Unproposed As Answer by Priyank Kansal Monday, May 07, 2012 5:48 AM

