2011-04-14 36 views
0

我有以下情形: 項目A包含2個接口A和B以及兩個服務端點EndpointA和EndpointB,每個實現匹配接口。 我有一個單元測試項目,它使用Cassinini來測試服務。我使用svcutil生成的代理在我的單元測試中創建客戶端對象。 下面是從單元測試項目我的app.config:WCF - EndpointNotFoundException

<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding name="basicHttp" closeTimeout="00:10:00" openTimeout="00:10:00" 
     receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" 
     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
     maxBytesPerRead="4096" maxNameTableCharCount="5242880" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    <binding name="BasicHttpBinding_IAdministration" closeTimeout="00:01:00" 
         openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
         allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
         maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
         messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
         useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    <binding name="BasicHttpBinding_IRetrieval" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 
    <binding name="BasicHttpBinding_IModification" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
      maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <security mode="None"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding>  
    </basicHttpBinding> 
</bindings> 
<client>  
    <endpoint address="http://localhost/MyServiceA.svc/MyServiceA" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRetrieval" 
     contract="IRetrieval" name="BasicHttpBinding_IRetrieval" /> 
    <endpoint address="http://localhost/MyServiceB.svc/MyService" 
     binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IModification" 
     contract="IModification" name="BasicHttpBinding_IModification" />  
</client> 

當我打電話ServiceA,它工作正常。然而,當我打電話ServiceB,我收到以下錯誤信息:

測試方法的MyMethod拋出異常: System.ServiceModel.EndpointNotFoundException:與Message 'HTTP://localhost/MyServiceB.svc/MyServiceB'由於EndpointDispatcher中的AddressFilter不匹配,無法在接收方處理。檢查發件人和收件人的EndpointAddresses是否同意。

發生了什麼事?謝謝。

+0

你是如何配置服務端點的? – 2011-04-14 18:55:31

回答

0

卡西尼號在端口80幾乎從來不聽你需要找出端口卡西尼監聽並使其固定的(使用項目屬性/網絡和默認值更改爲固定的端口號),並更新端點:

<endpoint address="http://localhost:<PORTNUMBER>/MyServiceB.svc/MyService" 
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IModification" 
    contract="IModification" name="BasicHttpBinding_IModification" /> 
+0

Aliostad,其他服務客戶端如何正常工作 - 它們都在同一個代理中定義,並且具有除名稱以外的相同配置條目? – laconicdev 2011-04-14 17:53:16

相關問題