Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 71679

Forum Post: CRM Dynamics 2013 Plugin calling WCF Service Error

$
0
0
Hi I have a CRM 2013 Plugin which calls a WCF service, the service fails with the following error 'The communication object, System.ServiceModel.ChannelFactory`1[ISupplyClaimsService], cannot be modified while it is in the Opening state', I also sometimes get that when the call is made to the service, the Plugin Registration tool crashes. Is is possible to call a WCF service from a Plugin? I see some posts on it online, but no concrete working solution is out there, not even in the CRM SDK. My CRM is on-premises 2013, plugin is registered out of Sandbox isolation(NONE), The WCF Service uses a named domain and not an IP address, its runs through HTTP protocol, Please see my code below. I have met all requirements with regards to plugins and external systems, but still no luck. I have also tested the service in a Console application,SOAP UI it works fine, just in the Plugin I am having issues. public void Execute(IServiceProvider serviceProvider) { ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService)); IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); if (context == null) { throw new ArgumentNullException("loaclContext"); } if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity supplyClaimsEntity = (Entity)context.InputParameters["Target"]; if (supplyClaimsEntity.LogicalName != "new_supplierclaimsupdate") { return; } IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId); string entityBeginUpload = "Start Upload"; try { BasicHttpBinding myBinding = new BasicHttpBinding(); myBinding.Name = "BasicHttpBinding_ISupplyClaimsService"; myBinding.Security.Mode = BasicHttpSecurityMode.None; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; EndpointAddress endPointAddress = new EndpointAddress(@" wmvapps01.tarsus.co.za/SupplyClaimsService.svc "); ChannelFactory factory = new ChannelFactory (myBinding, endPointAddress); ISupplyClaimsService channel = factory.CreateChannel(); channel.StartApplication(); factory.Close(); }

Viewing all articles
Browse latest Browse all 71679

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>