I have a service I am trying to consume in a unit test. At this point I'm just trying to instantiate the thing. After suffering the "Could not find default endpoint element that references contract" error for hours and unable to figure it out, I completely deleted out the consumer and started from scratch. All I did was add a service reference to my test project, point it at my service, hit "GO" and that's it. Still doesn't work. I didn't touch a line of code, yet it doesn't work right after I let VS build the thing.
Here is the relevant line in my app.config for the test project:
<client>
<endpoint address="http://mike-laptop/kbs/FFEDI/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEdiService"
contract="ServiceReference2.IEdiService" name="BasicHttpBinding_IEdiService" />
</client>
In my unit test, here is my method:
public void CreateWebServiceInstance()
{
ServiceReference2.EdiServiceClient webService = new ServiceReference2.EdiServiceClient();
string svcAddress = webService.Endpoint.Address.ToString();
Console.WriteLine("Address is: " + svcAddress);
Assert.IsTrue(svcAddress.Equals("http://mike-laptop/kbs/FFEDI/Service.svc")); // test
}
The error I get is:
System.InvalidOperationException: Could not find default endpoint element that references contract 'ServiceReference2.IEdiService' 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.
Again, I didn't change anything this time. Any ideas?