开发者

accessing a webservice through class library in .net3.5 vs2008

开发者 https://www.devze.com 2023-02-13 03:17 出处:网络
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.

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 hich consumes this webservice the same way usinfg 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. Also i had changed the names开发者_如何学运维pace of my class library and also changed it in settings and assembly files. the dll still has the old name :( I've added a reference of this class library in my website.

where am i going wrong.


If you put a WCF service reference into a class library, then you will get an app.config with the binding information created in that class library. Unfortunately when you reference the library, that config information isn't loaded.

You need to copy the portion of the app.config in the class library to your main application's config area. That will make it available when the service is called.


The service reference still needs to be added to the webform project as well, because the client connects using the settings in the web.config of the project that is running, not the class library.

0

精彩评论

暂无评论...
验证码 换一张
取 消