Reputation: 31
Yes, I know the question is probably a repeat, but bear with me here. I've tried what I've seen in ALL other questions of the same type and STILL haven't managed to get this working.
I'm working with .Net 4.0 in VS2012 Ultimate. I have a class library that's supposed to reference a web service. Going through the usual steps (Add Service Reference > enter service URI > Go > find the available service > give it a name > OK) creates the service reference and adds a system.serviceModel
tag in the app.config
file of my class library.
This class library is currently being referenced by a WinForms app that's passing data to it, to be validated with the returned data from web service. However, upon creation of the service client object...
SHWS.StaticXMLAPISoapClient wsc =
new SHWS.StaticXMLAPISoapClient();
...the code crashes with the error noted in the question title, "Could not find default endpoint element that references contract 'SHWS.StaticXMLAPISoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."
I have tried EVERYTHING I've found on the net, from copying the [class library name].dll.config
file to the output folder of the WinForms app, to copying the system.serviceModel
tag from one config file to the other, and still no luck.
I'm literally at my wit's end. Any help would be VERY appreciated, since this is one of the key points of the app I'm working on at the moment. Apologies for my ridiculous request, and thanks in advance for your time.
Upvotes: 0
Views: 7496
Reputation: 31
...You know, this is why I sometimes hate this world of software development. I removed the class library config file, moved the serviceModel
settings to the WinForms app, and specified the name of the endpoint binding I wanted, and by some stupid miracle, it decided to start working now.
SHWS.StaticXMLAPISoapClient wsc =
new SHWS.StaticXMLAPISoapClient("StaticXMLAPISoap");
Using that instantiation call instead of the one posted in the question, in addition to adding the system.serviceModel
settings to the WinForms app.config
file seems to have solved the issue and now I can communicate fine with the webservice.
Oh well. Such is the magical world of programmming.
I still don't know WHY it works like this, so if anyone feels like enlightening me, I'll very much appreciate it.
Upvotes: 0
Reputation: 10862
Have you tried adding the same system.serviceModel sections/settings to your WinForms app.config file ?
Upvotes: 7