在WAS中托管WCF服务

发布于 2024-12-19 15:26:37 字数 2718 浏览 1 评论 0原文

我需要一些有关在 WAS 中托管 WCF 服务的帮助。 我在 IIS 中托管了该服务,并通过 basicHttp 和 wsHttp 绑定进行访问。 但当我尝试将其托管在 WAS 并通过 tcp/ip 访问时,我似乎错过了一些东西。

我需要将其配置为通过端口 10000 上的 tcp 进行访问。

我在 Windows 功能中为非 HTTP 启用了 WCF 激活

该服务在默认网站、应用程序 mywcfapp 下发布

我创建了一个 BAT 文件以在端口 10000 上启用 net.tcp 绑定默认网站和 mywcfapp 如下:

%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='10000:*']
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/mywcfapp" /enabledProtocols:http,net.tcp

web.config 是

<services>
  <service name="MyWcfService">
    <clear />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
      listenUriMode="Explicit" />

    <endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
      binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />
    <endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
      binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />

  </service>
</services>

<bindings>
  <netTcpBinding>
    <binding name="PortSharingBinding" portSharingEnabled="true">
      <security mode="None" />
    </binding>
  </netTcpBinding>
</bindings>

但是,我似乎无法访问该服务。

当我尝试使用带有 uri 的 WcfTestClient 访问服务时

net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex

,出现以下错误

<Fault xmlns="http://www.w3.org/2003/05/soap-envelope">
<Code>
    <Value>Sender</Value>
    <Subcode><Value xmlns:a="http://www.w3.org/2005/08/addressing">a:DestinationUnreachable</Value>
    </Subcode>
</Code>
<Reason><Text xml:lang="ro-RO">
    The message with To 'net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex' 
    cannot be processed at the receiver, due to an AddressFilter mismatch 
    at the EndpointDispatcher.  
    Check that the sender and receiver's EndpointAddresses agree.
</Text></Reason>
</Fault>

如果我尝试使用 url(不指定端口)连接,

net.tcp://localhost/OneTest.Service/OneTest.Service.svc/mex

则会收到错误(仅保留重要部分)

Could not connect to net.tcp://localhost/mywcfapp/mywcfapp.svc/mex. 
The connection attempt lasted for a time span of 00:00:02.0041146. 
TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808.     
No connection could be made because the target machine actively refused it 127.0.0.1:808

I need some help with hosting a WCF service in WAS.
I hosted the service ok in IIS and accessed over basicHttp and wsHttp binding.
But it seems I miss something when trying to host it in WAS and access over tcp/ip.

I need to configure it for access over tcp on port 10000.

I enabled WCF activation for Non-HTTP in Windows Features

The service is published under default web site, application mywcfapp

I created a BAT file to enable net.tcp binding on port 10000 on default web site and mywcfapp as below:

%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='10000:*']
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/mywcfapp" /enabledProtocols:http,net.tcp

The web.config is

<services>
  <service name="MyWcfService">
    <clear />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
      listenUriMode="Explicit" />

    <endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
      binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />
    <endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
      binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />

  </service>
</services>

<bindings>
  <netTcpBinding>
    <binding name="PortSharingBinding" portSharingEnabled="true">
      <security mode="None" />
    </binding>
  </netTcpBinding>
</bindings>

However, it seems I cannot access the service.

When I try to access the service with WcfTestClient with the uri

net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex

I get the following error

<Fault xmlns="http://www.w3.org/2003/05/soap-envelope">
<Code>
    <Value>Sender</Value>
    <Subcode><Value xmlns:a="http://www.w3.org/2005/08/addressing">a:DestinationUnreachable</Value>
    </Subcode>
</Code>
<Reason><Text xml:lang="ro-RO">
    The message with To 'net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex' 
    cannot be processed at the receiver, due to an AddressFilter mismatch 
    at the EndpointDispatcher.  
    Check that the sender and receiver's EndpointAddresses agree.
</Text></Reason>
</Fault>

If I try to connect with url (w/o specifying port)

net.tcp://localhost/OneTest.Service/OneTest.Service.svc/mex

I get the error (kept only significant part)

Could not connect to net.tcp://localhost/mywcfapp/mywcfapp.svc/mex. 
The connection attempt lasted for a time span of 00:00:02.0041146. 
TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808.     
No connection could be made because the target machine actively refused it 127.0.0.1:808

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹梦 2024-12-26 15:26:37

这可能会有所帮助:

转到 IIS 管理器。
右键单击该应用程序。
选择管理应用程序->高级设置
在“行为”下,有一个“启用协议”字段。

确保它有 net.tcp

如果它只有 http,请将其更改为

http,net.tcp

This might help:

Go to IIS Manager.
Right click on the app.
Choose Manage Applications -> Advanced settings
Under Behavior, there is a field for Enabled Protocols.

Make sure it has net.tcp

If it just has http, change it to

http,net.tcp
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文