2012-07-24 32 views
3

我遇到了WCF測試客戶端的問題。我無法連接到我的web服務,因爲它使達不到這個錯誤:WCF - 無法獲取元數據,但在移除XML端點時起作用?

Error: Cannot obtain Metadata from http://xxx.xxxxxxxx.xxx/DPITerminal.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://xxx.xxxxxxxx.xxx/DPITerminal.svc
Metadata contains a reference that cannot be resolved: 'http://xxx.xxxxxxxx.xxx/DPITerminal.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://xxx.xxxxxxxx.xxx/DPITerminal.svc . The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..HTTP GET Error URI: http://xxx.xxxxxxxx.xxx/DPITerminal.svc There was an error downloading 'http://xxx.xxxxxxxx.xxx/DPITerminal.svc'.

這裏是我的web.config:Link

正如你所看到的,我已經有

<serviceMetadata httpGetEnabled="true" /> 

以及

<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="mex" contract="IMetadataExchange" /> 

如其他StackOverflow的問題建議。仍然不起作用。

我還注意到,當我評論以下端點:

<endpoint address="x" behaviorConfiguration="poxBehavior" binding="webHttpBinding" bindingConfiguration="web" contract="xxx.xxxxxxxx.xxxxxx.WebService.IDPITerminal" /> 

一切正常。所以我想我的XML端點有問題?這很奇怪,因爲XML端點共享JSON端點的綁定配置,而JSON端點沒有任何問題。

此外,讓我澄清,我只有WCF測試客戶端的問題。 XML Endpoint的JSON &工作正常。

編輯:

我想評論的XML端點,發佈,然後通過WCF測試客戶端連接。然後我取消註釋了XML Endpoint,重新發布。 WCF測試客戶端仍然有效 - 我的意思是我可以發送和接收數據。當我刷新服務時,無法獲取元數據錯誤再次彈出。

回答

4

看來WCF不允許爲2個端點使用相同的配置。

有變通方法來解決該問題:

  1. 變化bindingConfiguration端點address="x"web屬性web2
  2. 添加新的web2的webHttpBinding配置(複製網絡配置):

代碼新的綁定配置:

<webHttpBinding> 
    <binding name="web" ... /> 
    <binding name="web2" closeTimeout="00:10:00" openTimeout="00:10:00" 
     sendTimeout="00:10:00" allowCookies="true" maxBufferSize="2147483647" 
     maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="64" maxStringContentLength="2147483647" 
      maxArrayLength="8192" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
    </binding> 
</webHttpBinding> 

更新:

WCF測試客戶端是無法獲得的元數據webHttpBinding,因爲這樣的元數據不存在。 RESTfull服務不支持用於basicHttpBindingwsHttpBinding的WSDL或類似協議。當WCF測試客戶端試圖在兩種情況下都獲取元數據時(WCF測試客戶端出現故障時,WCF測試客戶端出現故障時),但由於某種原因,WCF測試客戶端設法解決了錯誤時,服務返回錯誤。很難說爲什麼沒有WCF測試客戶端源代碼。

錯誤跟蹤查看:

enter image description here

+2

我嘗試過了,它的工作。 WCF的行爲仍然非常奇怪。 – 2012-07-28 22:30:48