zoranpro
zoranpro

Reputation: 453

Using class library with WCF service in ASP.NET 5

In my project I have a class library that contains connections for WCF services.

In old ASP.NET MVC in order to use service methods I only needed to add bindings in my web.config and it would work properly.

The issue that I am having now is that when I call web service in ASP.NET5 I get this exception:

InvalidOperationException: Could not find default endpoint element that references contract 'xxx' 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.

Is there a way that I can add my binding in a similar way as I would do in old MVC apps?

Upvotes: 2

Views: 983

Answers (2)

mesut
mesut

Reputation: 2177

I was able to run by programattically config bindings. thanks to @wiktor-zychla comment.

var documentService = new DocumentServiceClient(
                                  new BasicHttpBinding(BasicHttpSecurityMode.None),
                                  new EndpointAddress("http://localhost:60205/DocumentService.svc"));

Upvotes: 0

Tarik.J
Tarik.J

Reputation: 131

I'm using the configuration below from an MVC app. When you add a reference to your WCF service using the add service ref dialog. A client section will get added to your System.ServiceModel section in your web.config. It should specify the endpoint which what seems to be missing based on the error you're getting.

Hope this helps

    <client>

  <endpoint address="http://address.to.your.service.com:8080/V3/ConfigService.svc" 
            binding="basicHttpBinding" 
            bindingConfiguration="ConfigService.V3.ConfigHttpServiceBinding" 
            contract="ConfigService.IConfigService" 
            name="ConfigService.V3.ConfigHttpService"/>
    </client

Upvotes: 1

Related Questions