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.
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>
....
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With