Routing multiple wcf services to a single wcf
-
2012年4月30日 14:07
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!!
- 編集済み Priyank Kansal 2012年4月30日 14:12
すべての返信
-
2012年5月1日 1:32モデレータHello, 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. -
2012年5月2日 5:27No, I am looking for the solution in WCF 4.0 Routing behaviour only.
.Net
-
2012年5月2日 6:16モデレータDo 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. -
2012年5月2日 7:01
Can I share my code with you?
.Net
-
2012年5月2日 7:13モデレータYou 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. -
2012年5月2日 7:22I didn't get you.
.Net
-
2012年5月2日 7:42モデレータWell, 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. -
2012年5月2日 8:07
Sorry Luo,
This site is not accessable here in my office. Is there having any other alternative?
Priyank
.Net
-
2012年5月2日 8:14モデレータOK. 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. -
2012年5月2日 9:31モデレータ
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.- 回答の候補に設定 Yi-Lun LuoModerator 2012年5月4日 9:29
- 回答の候補の設定解除 Priyank Kansal 2012年5月7日 5:48

