我有用.NET 4.0編寫的WCF服務庫。我有一個WCF應用程序(爲了在IIS中託管此服務)在同一個解決方案中。它包含WCF庫程序集引用和一個service.svc文件,該文件指向庫中的服務以及作爲WCF服務庫的app.config副本的web.config。 WCF應用程序被設置爲在IIS7中託管服務(虛擬目錄已設置)。同樣的解決方案包含一個ASP.NET Webforms解決方案,我已經添加了一個服務引用,指向我在IIS中託管的WCF服務(如前所述)。無法在IIS7中正確託管WCF服務
當我啓動此ASP.NET Web應用程序的一個實例時,我收到一條消息,指出「WCF服務已託管」,並且ASP.NET應用程序可以正確訪問它的數據。然而,當我嘗試訪問這個數據通過服務引用添加到一個不同的解決方案(指向IIS中託管的服務)在同一臺計算機上的MVC 2 Web應用程序,我得到一個「遠程服務器返回錯誤:( 405)方法不允許。「協議例外。但是,如果手動調用我用來從另一個解決方案託管WCF服務庫的WCF應用程序的實例,則MVC應用程序能夠訪問服務數據。
我使用VS2010 Beta 2作爲我的開發IDE。我一直堅持這個問題一段時間了。任何幫助,將不勝感激。
我服務的配置如下: -
<system.serviceModel>
<services>
<service behaviorConfiguration="CruxServices.BasicSearchServiceBehavior"
name="CruxServices.BasicSearch.BasicSearch">
<endpoint address="" binding="wsHttpBinding" name="WSBindingEndpoint" bindingConfiguration="WSBindingConfig"
contract="CruxServices.BasicSearch.Interfaces.IPropertyListFilter">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" name="MexEndpoint"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/CruxServices" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CruxServices.BasicSearchServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSBindingConfig">
<security mode="None">
<transport clientCredentialType="None"/>
<message establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
嗨西拉,謝謝你的回覆。我正在使用IIS 7.5附帶的Windows 7盒子上運行此操作。我安裝了VS2010,因此安裝了.NET 4.0,這是一個.NET 4.0 MVC 2應用程序。 – user206736 2009-11-10 08:08:39