简体   繁体   English

WCF 服务通过 net tcp 托管在 Windows 服务中

[英]WCF Service Hosted in Windows Service over net tcp

In my project I have one WCF Service which is hosted in a Windows Service.在我的项目中,我有一个 WCF 服务,它托管在 Windows 服务中。 I hosted the WCF Service in Windows Service over netTCPBinding and Installed Windows Service.我通过netTCPBinding和已安装的 Windows 服务在 Windows 服务中托管了 WCF 服务。 To access WCF service in my silverlight project I have added service reference of wcf.为了在我的 Silverlight 项目中访问 WCF 服务,我添加了 wcf 的服务引用。 But, when I am calling a method in WCF Service am getting the following error :但是,当我在 WCF 服务中调用方法时,出现以下错误:

Could not connect to net.tcp://localhost:8732/WCFHost/.无法连接到 net.tcp://localhost:8732/WCFHost/。
The connection attempt lasted for a time span of 00:00:03.2951885.连接尝试持续了 00:00:03.2951885 的时间跨度。
TCP error code 10013: An attempt was made to access a socket in a way forbidden by its access permissions.. TCP 错误代码 10013:尝试以访问权限禁止的方式访问套接字。
This could be due to attempting to access a service in a cross-domain way while the service is not configured for cross-domain access.这可能是由于在未将服务配置为跨域访问时尝试以跨域方式访问服务。 You may need to contact the owner of the service to expose a sockets cross-domain policy over HTTP and host the service in the allowed sockets port range 4502-4534.您可能需要联系服务的所有者以通过 HTTP 公开套接字跨域策略,并在允许的套接字端口范围 4502-4534 中托管该服务。

Please help me out.请帮帮我。

For same-machine connections rather make use of Named Pipe bindings.对于同机连接,请使用命名管道绑定。

It might help if you showed us your service and client side endpoint configurations.如果您向我们展示了您的服务和客户端端点配置,这可能会有所帮助。

EDIT : After reading up a bit on the error you're getting ( here among other sites), try changing the port number from 8732 to something between 4502-4534 as the error message suggests.编辑:在阅读了一些关于你得到的错误( 这里以及其他站点)之后,尝试将端口号从 8732 更改为 4502-4534 之间的某个值,如错误消息所示。

Keep same protocols at both the server and client end.在服务器端和客户端保持相同的协议。 May be your are calling the service with different protocols.可能是您正在使用不同的协议调用服务。 Also check if your are using nettcp, your are having access to the machine where service is hosted.还要检查您是否正在使用 nettcp,您是否可以访问托管服务的机器。

使用 basicHttpBinding 代替 netTCPBinding

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM