2011-06-13 51 views
0

我有一個wcf安寧服務啓動並運行。如果我使用WebServiceHost啓動webservice,我可以發出Get/Post沒有問題。我嘗試將wcf服務移動到本地盒子上的IIS 7.5上,但似乎無法完成。WCF Restful Service .NET 4 IIS 7.5問題(無法處理Action'消息)

我不斷收到以下錯誤,我嘗試從wcf服務中調用任何東西:(http:// wp9dbytr1k1:8081/service.svc/AnythingHereForGETorPUT)。我在虛擬目錄/設備上嘗試過,並且遇到同樣的問題。

The message with Action '' cannot be processed at the receiver, due to a  ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None). 

,如果我直接調用SVC文件(HTTP:// wp9dbytr1k1:8081/service.svc),它的快樂,並告訴我

「你已經創建了一個服務 爲了測試這項服務。 ,你需要創建一個客戶端,並使用它來調用服務,您可以使用從以下語法命令行工具的svcutil.exe做: svcutil.exe的http://wp9dbytr1k1:8081/FUU/service.svc?wsdl

的痕跡STRACK從跟蹤查看器沒有幫助:對不起,必須添加一個鏈接,不允許發佈圖片。 (ImageLink)

這裏是我的web.config

<system.serviceModel> 
    <bindings> 
     <mexHttpsBinding> 
     <binding name="NewBinding0" /> 
     </mexHttpsBinding> 
     <webHttpBinding> 
     <binding name="WebBinding"> 
      <readerQuotas maxDepth="524288" maxStringContentLength="524288" 
      maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" /> 
      <security mode="None"> 
      <transport clientCredentialType="None" proxyCredentialType="None" /> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="StoredProcBehaviors" name="StoredProcService.DataRetreivalService"> 
     <endpoint address="" binding="webHttpBinding" bindingConfiguration="WebBinding" 
      contract="StoredProcService.IDataRetreivalService"> 
      <identity> 
      <dns value="locahost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" 
      contract="StoredProcService.IDataRetreivalService" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://WP9DBYTR1K1:8081/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="StoredProcBehaviors"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

出於顯而易見的原因,這種感覺就像IIS設置,因爲它與WebServiceHost工作。我已經搜索了關於如何設置這些的錯誤/教程,並且對我來說一切似乎都很好。

有什麼建議嗎?

感謝

回答

4

要創建一個WCF REST端點,你需要的,除了使用的WebHttpBinding,有與它的終結點行爲。

<system.serviceModel> 
    <services> 
     <service behaviorConfiguration="StoredProcBehaviors" name="StoredProcService.DataRetreivalService"> 
     <endpoint address="" binding="webHttpBinding" bindingConfiguration="WebBinding" behaviorConfiguration="REST" 
      contract="StoredProcService.IDataRetreivalService"> 
      <identity> 
      <dns value="locahost" /> 
      </identity> 
     </endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="REST"> 
      <webHttp/> 
     </behavior> 
     <endpointBehaviors> 
    </behaviors> 
    </system.serviceModel> 

另一種選擇是使用WebServiceHostFactory在.svc文件,它的工作方式類似於WebServiceHost。在這種情況下,您甚至不需要web.config中的system.serviceModel部分。

<% @ServiceHost Service="StoredProcService.DataRetreivalService" Factory="System.ServiceModel.Activation.WebServiceHostFactory" Language="C#" debug="true" %> 
+0

哇......那簡單的呃?謝謝! – NickD 2011-06-13 16:55:40