Could not find endpoint element with Name and Contract from config file
Asked Answered
R

2

12

I have 3 project in my solution. First project is asp.net mvc(as client app) and other one is WCF service application and last one is workflow activity library. I added WCF service reference to workflow project and workflow project reference added to asp.net mvc. When I used wcf service in activity and start workflow from asp.net mvc I get this error:

Could not find endpoint element with name BasicHttpBinding_IService and contract IService 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 name could be found in the client element.

This my workflow activity library app.config file content:

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService1" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:30717/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IService1" contract="Service1.IService1"
                name="BasicHttpBinding_IService1" />
        </client>
    </system.serviceModel>
</configuration>

And this is my wcf project web.config file content:

<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="http" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

And this is my asp.net mvc web.config file content:

<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:30717/Service1.svc" binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceTest.IService1"
          name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>
</configuration>

And this is my code for run workflow in asp.net mvc controller:

wf.Activity1 mm = new wf.Activity1();//wf is reference added from workflow project
mm.arg1 = "12".ToString() ;
IDictionary<string, object> res = WorkflowInvoker.Invoke(mm);
ViewBag.res = res["arg2"].ToString();

I googled for a day and unfortunately I didn't get result. Thanks for your guides.

Edit: This is my project for more help.

Rolan answered 28/8, 2016 at 17:9 Comment(0)
E
9

Remove the '1' from both contract and name attributes in the workflow config file.

The BasicHttpBinding_IService class generated by VS, when instantiated, it looks up on config for some suitable endpoint that match 2 conditions:

  • has the name of the class (BasicHttpBinding_IService, if nothing is passed to the constructor). Namespace should be indicate too. In this, the name of the end point should be .BasicHttpBinding_IService
  • has a contract supported by the class.

To prevent a further error, you should check the name of svc file, the name ends with '1' too. Binding configuration is ok since it exists on the binding section with the exactly same name.

Here a simplified version of the config:

<configuration>
<system.serviceModel>
    <client>
        <endpoint address="http://localhost:30717/Service.svc" binding="basicHttpBinding" contract="Service1.Service" name="<namespace>.BasicHttpBinding_IService" />
    </client>
</system.serviceModel>

Also you can use Visual Studio WFC Service configuration tool (shortcut on tools menu), to edit config files of either clients and services.

Enterostomy answered 31/8, 2016 at 22:20 Comment(5)
I add Dowork activity to wf activity file( Dowork is my operation name in wcf service application) and when I run my project by step into(f11) I get error in send/receive sequence in Dowork activity.Rolan
I think you need to break down the problem. An test with one simple service and a client would help understanding what is going behindEnterostomy
I forgot to put the namespace of the class as sufix, The answer is updated to reflect this.Enterostomy
Whats your means of <namespace>Commonable
It is to be replace by the class namespace.Enterostomy
C
3

the error message is quite correct: you don't have any service endpoints configured in your WCF Services Web.config

add a services node and configure the endpoint like this:

 .... 
 <system.serviceModel>
    <services>
      <service name="MyService">
        <endpoint address="" binding="basicHttpBinding" contract="Service1.IService1" />
      </service>
    </services>
    <behaviors>
    ....
Cele answered 31/8, 2016 at 8:40 Comment(1)
I used your suggested config in my wcf config file but I get that error.Rolan

© 2022 - 2024 — McMap. All rights reserved.