我创建了一个托管在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