我对已部署到IIS的服务有以下配置。我可以使用wsHttpBinding端点的URL添加服务的服务引用,但我无法使用URL将其添加到mexHttpBinding端点(并且我想切换客户端以使用netTcpBinding)无法使用IIS中托管的netTcpBinding添加WCF服务的服务引用
我得到的错误是:
下载'http:// ServerName:98/MyService.svc/mex'时出错。
请求失败,HTTP状态400:错误的请求。
元数据包含无法解析的引用:'http:// ServerName:98/MyService.svc/mex'。
元数据包含无法解析的引用:'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绑定在相关端口上启用和配置。它们也都在同一台服务器上运行不同的站点和独立的应用程序池(并且这两个应用程序池都以相同的身份运行)。
任何帮助,将不胜感激,谢谢。
正如我所说,我最初开始时没有netTcpBinding的地址,只是“mex”作为mexHttpBinding的地址,并没有工作。这是我在其他服务中使用的配置。 – alimbada 2012-01-09 09:58:55