Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 317
Farshid Shekari Avatar asked Aug 28 '16 17:08

Farshid Shekari


2 Answers

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>
    ....
like image 195
user1859022 Avatar answered Nov 06 '22 10:11

user1859022


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.

like image 8
MiguelSlv Avatar answered Nov 06 '22 10:11

MiguelSlv