Kevin Johnson
Kevin Johnson

Reputation: 57

Could not find default endpoint element that references contract ServiceReference1.Service1Soap in the ServiceModel client configuration section

I have a problem really similar to a lot of other questions in this forum, but neiter of the solutions work for me - perhaps because I don't get them.

I have a VERY simple ASP.NET web service with just 4 simple methods. To test it, I connected to it from a newly created Console Application and it works absolutely perfect - just added the URL and had Visual Studio generate the client code (it generated 2 end points of which I needed to delete 1 in order to make it work, by I guess that's not important).

Then I tried doing the same thing in a User Control project (meaning that it's a class library). Then suddenly it throws an exception with a message like the on in the title of this questions.

I run the user control project locally in Visual Studio since it is still being tested.

I even tried copy/pasting the service model section from the other project (where it worked) into my app.config of the user control project - still not working.

Any ideas?

EDIT: This is the servicemodel section of the app.config file

  <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="Service1Soap" />
  </basicHttpBinding>
  <customBinding>
    <binding name="Service1Soap12">
      <textMessageEncoding messageVersion="Soap12" />
      <httpTransport />
    </binding>
  </customBinding>
</bindings>
<client>
  <endpoint address="http://localhost:49737/Service1.asmx" binding="basicHttpBinding"
    bindingConfiguration="Service1Soap" contract="ServiceReference1.Service1Soap"
    name="Service1Soap" />
</client>

Upvotes: 0

Views: 2452

Answers (2)

Breeno
Breeno

Reputation: 3166

For me, after copying the serviceModel section from my Class Library to the ASP.Net website's web.config, I was still getting this error.

After some time, I realised you had to fully qualify the contract attribute of the endpoint, because the service is in a class library with a different namespace..

I.e. in the config where is says... contract="MyService.SoapService" etc You need to fully qualify this... contract="MyClassLibraryName.Namespace.MyService.SoapService".

Conor

Upvotes: 1

dreamweiver
dreamweiver

Reputation: 6002

@kevin johnson : I am not sure what do you mean by 'User Control Project'.copy pasting the service model configuration from working project to your app.config wont work,because when you have to use a web service , you either have to add the reference file with app config file which will be generated from svcutil.exe or by adding the web service to existing project as 'service reference' never try to alter the configuration file(app.config or web.config ) unless you know what your doing.

Upvotes: 0

Related Questions