如何使用.net.tcp绑定托管两个WCF服务 [英] How to host two WCF services with .net.tcp binding

查看:82
本文介绍了如何使用.net.tcp绑定托管两个WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想托管两项服务

1.服务1(位于D盘)

基于xml配置的配置处理数据

net.tcp:// ServerIP / Pune_service

2.服务2(位于E驱动器上)

基于xml中配置的配置处理数据

net.tcp:// ServerIP / Mumbai_service



现在我试图在两个不同的Windows服务中使用net.tcp绑定来托管这些服务

Windows服务1成功启动

但是当试图启动第二个Windows服务时我得到错误即

AddressAlreadyInUseException。



我尝试了什么:



i尝试端口共享启用

WCF中的端口共享功能 [ ^ ]



但没有工作

i want to host two services
1. Service 1 (located on D Drive)
process data based on configuration configured in xml
net.tcp://ServerIP/Pune_service
2. Service 2 (located on E Drive)
process data based on configuration configured in xml
net.tcp://ServerIP/Mumbai_service

now i tried to host these services with net.tcp binding in two different Windows Service
Windows service 1 Started Sucessfully
but when tried to start second windows service i'am getting Error i.e.
AddressAlreadyInUseException.

What I have tried:

i tried with port sharing enable
Port Sharing Features in WCF[^]

but didnt work

推荐答案

您必须将每个TCP / IPListener定义为在另一个端口上,例如端口12001和12002.



如果他们都试图在同一端口上侦听,那么它们将发生冲突并生成AddressAlreadyInUseException。 />


另一种方法是使用前端服务来监听单个端口,然后根据其类型或定义的目标将请求传递给每个服务( Pune或Mumbai) - 可能使用名称管道或类似的东西。
You must define each TCP/IP "Listener" to be on a different port, such as ports 12001 and 12002.

If they are both trying to listen on the same port then they will clash and generate the AddressAlreadyInUseException.

An alternative is to have a "front-end" service that does the listening on a single port and then passes the requests to each service based on it's type or defined destination ("Pune" or "Mumbai") - possibly using names pipes or something similar.


这篇关于如何使用.net.tcp绑定托管两个WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆