gpt4 book ai didi

wcf - 无法使用 IIS 中托管的 netTcpBinding 添加 WCF 服务的服务引用

转载 作者:行者123 更新时间:2023-12-04 18:40:37 26 4
gpt4 key购买 nike

我对已部署到 IIS 的服务进行了以下配置。我可以使用 wsHttpBinding 端点的 URL 为服务添加服务引用,但我不能使用 mexHttpBinding 端点的 URL 添加它(并且我想切换客户端以使用 netTcpBinding)

我得到的错误是:

There was an error downloading 'http://ServerName:98/MyService.svc/mex'.

The request failed with HTTP status 400: Bad Request.

Metadata contains a reference that cannot be resolved: 'http://ServerName:98/MyService.svc/mex'.

Metadata contains a reference that cannot be resolved: 'http://ServerName:98/MyService.svc/mex'.

<system.web>
<compilation debug="true"
targetFramework="4.0" />
<customErrors mode="Off"/>
</system.web>

<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding_MyService" />
</netTcpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding_MyService"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehaviour"
name="MyService.MyService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding_MyService"
name="MyServiceEndpoint"
contract="MyService.IMyService" />
<endpoint address="net.tcp://ServerName:198/MyService.svc"
binding="netTcpBinding"
bindingConfiguration="netTcpBinding_MyService"
name="MyServiceNetTcpEndpoint"
contract="MyService.IMyService" />
<endpoint address="http://ServerName:98/MyService.svc/mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://ServerName:98/" />
<add baseAddress="net.tcp://ServerName:198/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"
policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<windowsAuthentication includeWindowsGroups="true"
allowAnonymousLogons="false" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

最奇怪的是,此配置几乎是从我配置和部署的另一个服务中逐字复制的,并且我能够使用 mexHttpBinding 端点成功地将服务引用添加到客户端。原始服务的配置是这样的:

<system.web>
<compilation debug="true"
targetFramework="4.0" />
<customErrors mode="Off"/>
</system.web>

<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding_MyOtherService" />
</netTcpBinding>
<wsHttpBinding>
<binding name="wsHttpBinding_MyOtherService"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" />
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehaviour"
name="MyOtherService.MyOtherService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding_MyOtherService"
name="MyOtherServiceEndpoint"
contract="MyOtherService.IMyOtherService" />
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="netTcpBinding_MyOtherService"
name="MyOtherServiceNetTcpEndpoint"
contract="MyOtherService.IMyOtherService" />
<endpoint address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
name="MyOtherServiceMexHttpBindingEndpoint"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://ServerName:97/" />
<add baseAddress="net.tcp://ServerName:970/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"
policyVersion="Policy15" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<windowsAuthentication includeWindowsGroups="true"
allowAnonymousLogons="false" />
</serviceCredentials>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

您会注意到,配置中唯一相关的差异是 netTcpBinding 端点和 mexHttpBinding 端点的地址。最初,我开始时它们都是空的,但由于我一直在尝试让它工作,所以我在其中添加了显式地址。

此外,这两个服务在 IIS 中的配置相同,即在相关端口上启用和配置 net.tcp 绑定(bind)。他们还在同一台服务器上各自运行不同的站点和不同的应用程序池(并且两个应用程序池都在相同的身份下运行)。

如有任何帮助,我们将不胜感激。

最佳答案

解决了。我们有一个 Web.{Environment}.config 用于我们部署到的每个环境,并且由于 Web.config 上的文件锁定(可能未从 TFS check out ),在构建时未通过 Web.config 复制正确的配置...

其中一个我真的应该首先检查,但是当它以前一直工作然后突然没有警告地坏了我从来没有想过检查。

关于wcf - 无法使用 IIS 中托管的 netTcpBinding 添加 WCF 服务的服务引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8762947/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com