2012-02-06 33 views
3

我有一個WCF的Web服務我正在我的本地機器上測試,這是給我一個headscratcher。WCF無法找到端點配置問題

我的服務配置,像這樣:

<system.serviceModel> 
    <services> 
     <service name="GHMDatroseIntegration.GHMDatroseWCFService.DatroseService" 
       behaviorConfiguration="DatroseServiceBehavior"> 
     <endpoint 
      address="mex" 
      binding="basicHttpBinding" 
      contract="GHMDatroseIntegration.GHMDatroseWCFService.IDatroseService" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="DatroseServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

我的客戶端配置,像這樣:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IDatroseService" 
      closeTimeout="00:02:00" openTimeout="00:01:00" 
      receiveTimeout="00:10:00" sendTimeout="00:02:00" 
      allowCookies="false" bypassProxyOnLocal="false" 
      hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="524288" maxBufferPoolSize="524288" 
      maxReceivedMessageSize="524288" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas 
       maxDepth="32" maxStringContentLength="524288" 
       maxArrayLength="524288" maxBytesPerRead="524288" 
       maxNameTableCharCount="524288" /> 
      <security mode="None"> 
       <transport clientCredentialType="None" proxyCredentialType="None" 
          realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint name="BasicHttpBinding_IDatroseService" 
      address="http://localhost/DatroseWCFService/DatroseService.svc" 
      behaviorConfiguration="DatroseServiceBehavior" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IDatroseService" 
      contract="DatroseWCFService.IDatroseService" /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="DatroseServiceBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 

我收到的錯誤是:

有沒有終點在聽http://localhost/DatroseWCFService/DatroseService.svc可能 接受該消息。這通常是由不正確的地址或SOAP操作引起的。有關更多詳細信息,請參閱InnerException(如果存在)。

...然而,如果我瀏覽到的位置我得到的服務屏幕,所以它似乎設置正確。

我敢肯定,這與我的終端配置有關,但我無法弄清楚它們應該是什麼樣子。一些幫助將在這裏讚賞。

UPDATE whups我把錯誤的錯誤信息。現在它已經修復。

更新2每什麼,我相信已經提出在這些回答,我已經改變了我的服務器配置到:

<system.serviceModel> 
    <services> 
     <service name="GHMDatroseIntegration.GHMDatroseWCFService.DatroseService" 
       behaviorConfiguration="DatroseServiceBehavior"> 
     <endpoint 
      address="/svc" 
      binding="basicHttpBinding" 
      contract="GHMDatroseIntegration.GHMDatroseWCFService.IDatroseService" /> 
     <endpoint 
      address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="DatroseServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

和我的客戶端配置:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="BasicHttpBinding_IDatroseService" 
      closeTimeout="00:02:00" openTimeout="00:01:00" 
      receiveTimeout="00:10:00" sendTimeout="00:02:00" 
      allowCookies="false" bypassProxyOnLocal="false" 
      hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="524288" maxBufferPoolSize="524288" 
      maxReceivedMessageSize="524288" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
      <readerQuotas 
       maxDepth="32" maxStringContentLength="524288" maxArrayLength="524288" 
       maxBytesPerRead="524288" maxNameTableCharCount="524288" /> 
      <security mode="None"> 
       <transport clientCredentialType="None" proxyCredentialType="None" 
         realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
    </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint name="BasicHttpBinding_IDatroseService" 
      address="http://localhost/DatroseWCFService/DatroseService.svc/svc" 
      behaviorConfiguration="DatroseServiceBehavior" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_IDatroseService" 
      contract="DatroseWCFService.IDatroseService" /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="DatroseServiceBehavior"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 

,當我運行這我現在得到一個400(錯誤的請求)錯誤。我不確定這是向前還是向後退步。我是否創造了一個新問題,還是讓我清除了下一個問題?

更新3

在蔦的意見,我改變了這個服務器的配置:

<system.serviceModel> 
    <services> 
     <service name="GHMDatroseIntegration.GHMDatroseWCFService.DatroseService" behaviorConfiguration="DatroseServiceBehavior"> 
      <endpoint contract="GHMDatroseIntegration.GHMDatroseWCFService.IDatroseService" binding="basicHttpBinding" address="http://localhost/DatroseWCFService/DatroseService.svc"/> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="DatroseServiceBehavior"> 
       <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
       <serviceMetadata httpGetEnabled="true"/> 
       <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
       <serviceDebug includeExceptionDetailInFaults="true"/> 
       <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

...然而,當我瀏覽到這個地址,我得到了一個黃屏的死亡:

'/ DatroseWCFService'應用程序中的服務器錯誤。
當在配置中將'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' 設置爲true時,端點需要指定 的相對地址。如果您在 端點上指定相對偵聽URI,則地址可以是絕對地址。爲了解決這個問題, 指定了端點 'http://localhost/DatroseWCFService/DatroseService.svc'的相對uri。

...所以,我試着讓它成爲這樣的相對路徑:

<endpoint 
    address="localhost/DatroseWCFService/DatroseService.svc" 
    binding="basicHttpBinding" 
    contract="GHMDatroseIntegration.GHMDatroseWCFService.IDatroseService" /> 

...但發佈後,我得到了404錯誤。客戶端的端點配置爲這樣:

<endpoint name="BasicHttpBinding_IDatroseService" 
    address="http://localhost/DatroseWCFService/DatroseService.svc" 
    behaviorConfiguration="DatroseServiceBehavior" 
    binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_IDatroseService" 
    contract="DatroseWCFService.IDatroseService" /> 

UPDATE 4 每marc_s'的建議,我刪除了來自客戶端的綁定配置,所以我的配置是這樣的:

<system.serviceModel> 
    <client> 
     <endpoint address="http://localhost/DatroseWCFService/DatroseService.svc" behaviorConfiguration="DatroseServiceBehavior" 
     binding="basicHttpBinding" 
     contract="DatroseWCFService.IDatroseService" name="BasicHttpBinding_IDatroseService" /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
      <behavior name="DatroseServiceBehavior"> 
       <dataContractSerializer maxItemsInObjectGraph="10000000"/> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 

和我服務器配置如下所示:

<system.serviceModel> 
    <services> 
     <service name="GHMDatroseIntegration.GHMDatroseWCFService.DatroseService" behaviorConfiguration="DatroseServiceBehavior"> 
      <endpoint contract="GHMDatroseIntegration.GHMDatroseWCFService.IDatroseService" binding="basicHttpBinding" address=""/> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="DatroseServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true"/> 
       <serviceDebug includeExceptionDetailInFaults="true" httpsHelpPageEnabled="true" httpHelpPageEnabled="true"/> 
       <dataContractSerializer maxItemsInObjectGraph="10000000"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 

我不再收到404錯誤。

但是,我確實得到了一個400(ProtocolException,Bad Request),沒有得到它所得到的信息或者它爲什麼壞的信息。我希望我已經超越了終端問題,進入了一個全新的服務配置地獄。

UPDATE 5

每請求,我服務的 「骨架」(我假設界面會做什麼?):

[ServiceContract] 
public interface IDatroseService 
{ 

    [OperationContract] 
    bool SubmitPayableTransaction(List<InvoiceItem> invoices); 

    [OperationContract] 
    Dictionary<string, bool> ValidateAccounts(List<string> accounts); 

    [OperationContract] 
    Dictionary<string, int> GetVendor1099Types(List<string> vendors); 

    [OperationContract] 
    Dictionary<string, string> GetPaymentTerms(List<string> vendors); 

} 
+0

您的webservice位於端口80?!? – deltree 2012-02-06 19:59:57

+0

我遇到了這個問題。一個有用的項目是使用提琴手。它可能會請求一個crossdomainpolicy.xml(名稱可能很不一致),導致它失敗。另外我錯誤地配置了我的數據庫連接,它拋出了錯誤,因此服務沒有在監聽。嘗試尋找這些類型的項目,看看這是否導致它。您的服務配置可能是正確的,但其他可能是錯誤的。 – 2012-02-06 20:00:47

+0

在服務器的web.config文件中指定一個端點地址(http://localhost/DatroseWCFService/DatroseService.svc) - http://msdn.microsoft.com/en-us/library/ms733749.aspx – 2012-02-06 20:01:10

回答

16

所以我假設你的服務裏面IIS託管,右??

所以你的*.svc居住的虛擬目錄基本上定義了你的服務地址 - 這個地址是否正確?

另外:你有「相對」的mex地址的服務端點

<endpoint 
    address="mex" 

我相信這是一個非常糟糕的主意 - MEX代表元數據交換,我也使用該解決了常規的服務端點它只是違反最少意外原則 - 如果端點稱爲MEX,我期待它BE元數據交換終結 - 不是一般的服務端點...

反正 - 與常規的地址,完整的服務地址就變成了:

http://yourserver/DatroseWCFService/DatroseService.svc/mex 

如果你調用該地址爲您服務 - 你得到迴應?

更新:不知道你是如何試圖測試這個。這是一個SOAP Web服務 - 您將在瀏覽器中看到服務的「登錄頁面」(「幫助」頁面),但要測試服務本身,您需要使用支持SOAP的測試工具(如 WCF Test ClientSoapUI) - 您無法通過瀏覽其Web地址來測試SOAP Web服務。
好的,所以你通過調用測試應用程序的服務來測試這個應該肯定有效!

更新#2:,因爲你在IIS託管本(右),你的服務地址基本上是由虛擬目錄,你* .svc文件的生活定義。所以我的下一個嘗試將是:只要讓這個地址成爲你的服務地址。

服務端配置更改爲:

<service name="GHMDatroseIntegration.GHMDatroseWCFService.DatroseService" 
     behaviorConfiguration="DatroseServiceBehavior"> 
    <endpoint 
     address="" <!-- define nothing here - just let the *.svc file determine your service address --> 
     binding="basicHttpBinding" 
     contract="GHMDatroseIntegration.GHMDatroseWCFService.IDatroseService" /> 
    <endpoint 
     address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
</service> 

和你客戶端配置到:

<endpoint name="BasicHttpBinding_IDatroseService" 
    address="http://localhost/DatroseWCFService/DatroseService.svc" 
    behaviorConfiguration="DatroseServiceBehavior" 
    binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_IDatroseService" 
    contract="DatroseWCFService.IDatroseService" /> 

這是否工作?

下一次嘗試是使用客戶端配置沒有bindingConfiguration=值 - 因爲這是你在做什麼的服務器上,太 - 只是絕對裸機basicHttpBinding沒有任何修改 - 這是否工作? ?

+0

+1我幾乎已經寫完答案了:)問題是他只有一個mex端點,實際服務丟失 – 2012-02-06 20:03:05

+0

Web服務在'http: //本地主機/ DatroseWCFService/DatroseService.svc'。我的地址應該是什麼樣子?空白?別的東西?我必須承認,我只是在跟隨我在互聯網上找到的「指導」指南,這對我來說只是希臘的一部分而已。 – 2012-02-06 20:11:21

+0

請參閱我的更新。 – 2012-02-06 20:52:02