我對已部署到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