我創建了一個託管在Windows服務中的WCF服務。我使用svcutil創建了一個代理 「svcutil.exe http://localhost:8000/ServiceModelSamples/FreeServiceWorld?wsdl」消費WCF服務
它生成了一個output.config文件和代理類。
的output.config具有以下元素
<client>
<endpoint address="http://localhost:8000/ServiceModelSamples/FreeServiceWorld"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWeather"
contract="IWeather" name="WSHttpBinding_IWeather">
<identity>
<servicePrincipalName value="host/sdfsf.sdfs.com" />
</identity>
</endpoint>
</client>
我創建了一個網站(如客戶端),並增加了一個新的C#文件(MyFile.cs)進去。我將代理類的內容複製到MyFile.cs中。 [該output.config不會被複制到網站]
在ASPX的代碼behnid,我使用以下代碼 WeatherClient客戶=新WeatherClient(「WSHttpBinding_IWeather」);
它拋出一個例外「中的ServiceModel客戶端配置節無法與名稱查找端點元素‘WSHttpBinding_IWeather’和合同‘IWeather’。」
能否請你幫我瞭解這裏的缺失的一環?
確切的說 - 它必須在''標籤下進入'web.config'。 –
2010-05-22 12:02:39
感謝你們兩個......它的工作。在你們的幫助下,我最終創建並使用了一個WCF服務 - 端到端。 你也可以參考下面的內容來看看我面臨的挑戰http://stackoverflow.com/questions/2887588/wcf-using-windows-service – Lijo 2010-05-22 12:10:24