Consuming a WCF Service
- by Lijo
Hi
I created a WCF service which is hosted in windows service. I created a proxy using svcutil
“svcutil.exe http://localhost:8000/ServiceModelSamples/FreeServiceWorld?wsdl”
It generated an output.config file and proxy class.
The output.config has the following element
<client>
<endpoint address="http://localhost:8000/ServiceModelSamples/FreeServiceWorld"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWeather"
contract="IWeather" name="WSHttpBinding_IWeather">
<identity>
<servicePrincipalName value="host/D471DTRV.ustr.com" />
</identity>
</endpoint>
</client>
I created a website (as client) and added a new C# file (MyFile.cs) into it. I copied the contents of the proxy class into MyFile.cs.
[The output.config is not copied to the web site]
In the code behnid of aspx, I am using the following code
WeatherClient client= new WeatherClient("WSHttpBinding_IWeather");
It throws an exception as “Could not find endpoint element with name 'WSHttpBinding_IWeather' and contract 'IWeather' in the ServiceModel client configuration section.”
Could you please help me to understand the missing link here?
Thanks
Lijo