我在這裏遇到一個很奇怪的問題。爲了簡單起見,我創建了一個項目,目的是在大型應用程序框架之外測試問題,並且仍然遇到了Visual Studio 2010中的WCF中的錯誤或與我的WCF新手技能集有關的問題:)WCF端點和綁定配置問題
這裏是問題:
我有一個WCF端點,我創建了一個名爲「SimpleMethod」的MVC3項目。該方法在應用程序根目錄下的.svc文件內運行,並返回一個布爾值。
使用「WCF服務配置編輯器」我已將端點添加到我的Web.Config以及一個名爲「LargeImageBinding」。
這裏的服務:
[OperationContract]
public bool SimpleMethod()
{
return true;
}
因爲Web.config通過配置工具生成的:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="LargeImageBinding" closeTimeout="00:10:00" />
</wsHttpBinding>
</bindings>
<services>
<service name="WCFEndpoints.ServiceTestOne">
<endpoint address="/ServiceTestOne.svc" binding="wsHttpBinding"
bindingConfiguration="LargeImageBinding" contract="WCFEndpoints.IServiceTestOne" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
服務呈現很好,你可以看到終點的時候你導航到:http://localhost:57364/ServiceTestOne.svc - 現在,當我創建一個單獨的項目來使用該服務時,會出現問題。我爲上述項目的運行實例添加服務引用,將其指向:http://localhost:57364/ServiceTestOne.svc
這是奇怪的部分。該服務自動生成得很好,但在web.config中所產生的端點這樣的長相:
<client>
<endpoint address="http://localhost:57364/ServiceTestOne.svc/ServiceTestOne.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceTestOne"
contract="ServiceTestOne.IServiceTestOne" name="WSHttpBinding_IServiceTestOne">
正如你可以看到它列出了地址的「ServiceTestOne.svc」部分的兩倍!
當我做的服務我得到以下錯誤的電話:
遠程服務器返回錯誤:(404)未找到。
我試圖在上面的配置中刪除端點地址末尾多餘的「/ServiceTestOne.svc」,並得到相同的確切錯誤。
現在,如果我回到WCF應用程序並刪除Web.Config中的自定義端點和綁定引用(「services」和「bindings」標記中的所有內容),然後返回到使用者應用程序,更新對該服務的引用,並調用SimpleMethod().... BOOM的工作方式就像一個魅力,我找回一個布爾值設置爲true。
事情是,我需要進行自定義綁定配置以允許訪問默認設置以外的服務,並且從我所知道的情況來看,任何嘗試創建自定義綁定都會使端點看起來運行良好,但在實際的方法調用時失敗。
任何人都可以看到我如何把它放在一起的任何缺陷?感謝您的時間 - 我一直在這個圈子裏跑了大約一週!
感謝拉米羅!這工作!我有另一個問題,這是相關的,我希望你有機會看看它:[鏈接](http://stackoverflow.com/questions/5158874/wcf-configuration-for-large-images) – CodeAbundance 2011-03-01 18:46:46
其實,這裏是鏈接到我的新問題:[鏈接](http://stackoverflow.com/questions/5183810/wcf-configuration-issues-on-shared-hosting) – CodeAbundance 2011-03-03 20:52:40