Click here to Skip to main content
15,616,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I had a webservice which I was directly accessing from my webform. I used a service reference in my wesite and used a serviceclient on my webform which worked fine.

Now I removed the service reference from my website and created a class library Which consumes this webservice the same way using a service reference and service client in the class.

When I try to use this class library now it gives me an error that no default endpoint found for the contract in class library. It creates the service client but fails when I do serviceclient.method-name. I checked in the object browser and under the classlibrary there's a node for service and under it I found service client and all the methods under service client are present. Also putting into debug I checked the service client object and serviceclient.method was available in watch window but fails in code.

I've added a reference of this class library in my website.

Where am i going wrong? :doh:
Updated 23-Feb-11 5:15am
jim lahey 23-Feb-11 11:39am    
Where are you configuring your service client?
Sandeep Mewara 23-Feb-11 13:59pm    
OP said: In Class Library
fififlowertot 23-Feb-11 11:41am    
In Class Library

1 solution

The easiest way is for you to re-add the web service reference in your web project so that the appropriate configuration values are added to you web.config file for the site. When the class library is referenced by the website, the configuration values in the web.config for the service will then be available to the class library objects as well. Leave the reference in both projects as it just makes life easier.
Share this answer
Espen Harlinn 25-Feb-11 6:30am    
Solid advice, my 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900