tags:

views:

41

answers:

1

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/sdfsf.sdfs.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?

+2  A: 

You need to add the elements in output.config to the web.config of the web site for the client to know where to look for the service. If the client isn't running on the same machine as the service you will need to exchange localhost for the IP address or host name of the machine running the service.

Anders Abel
to be exact - it has to go into `web.config` under the `<system.serviceModel>` tag.
marc_s
Thanks to both of you... It worked. With the help of you people, at last, I created and consumed a WCF service - end to end. You may refer the following also to see on of the challenges that I faced http://stackoverflow.com/questions/2887588/wcf-using-windows-service
Lijo