Lijo
Lijo

Reputation: 375

Consuming a WCF Service

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?

Upvotes: 1

Views: 1763

Answers (1)

Anders Abel
Anders Abel

Reputation: 69250

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.

Upvotes: 2

Related Questions