Hi all,
I'm currently developing on CRM 2013 on-premise and have been trying to develop a plug in that will ultimately send CRM data to an external system via their web service.
I have created a plugin and added a method that logs into the service which is called from ExecutePostContactUpdate. When I registered the plugin in the Sandbox the plugin errored out with the following:
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>System.Security.SecurityException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #904A5CD2</Message>
When I then select an Isolation mode of None I get the following which, while a slight improvement is still not working:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: There was no endpoint listening at xxx.com/.../basic that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:string">0</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>SubErrorCode</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>There was no endpoint listening at https://xxx.com/ExteranlService/basic that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.</Message>
<Timestamp>2017-08-18T09:44:53.8400131Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText>
[IVPContact: IVPContact.PostContactUpdate]
[f882f15c-5183-e711-86c0-005056a95391: IVPContact.PostContactUpdate: Update of contact]
Entered IVPContact.PostContactUpdate.Execute(), Correlation Id: 810a2ba9-8821-4417-91ce-ae32d1c54ad2, Initiating User: aef9440c-b1e1-e311-8a43-005056a95391
IVPContact.PostContactUpdate is firing for Entity: contact, Message: Update, Correlation Id: 810a2ba9-8821-4417-91ce-ae32d1c54ad2, Initiating User: aef9440c-b1e1-e311-8a43-005056a95391
Exiting IVPContact.PostContactUpdate.Execute(), Correlation Id: 810a2ba9-8821-4417-91ce-ae32d1c54ad2, Initiating User: aef9440c-b1e1-e311-8a43-005056a95391
</TraceText>
</OrganizationServiceFault>
I know that the code works as I have tested it in a separate console app and I can connect without issue.
The code in the plugin is as follows:
protected void ExecutePostContactUpdate(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException("localContext"); } // TODO: Implement your custom Plug-in business logic. IPluginExecutionContext context = localContext.PluginExecutionContext; IOrganizationService service = localContext.OrganizationService; if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity entity = (Entity)context.InputParameters["Target"]; if (entity.LogicalName == "contact") { string loginTest = ivpLogin(); throw new InvalidPluginExecutionException(loginTest); } } } private string ivpLogin() { BasicHttpBinding binding = new BasicHttpBinding(); binding.Name = "BasicHttpBinding_ExternalWebService"; binding.CloseTimeout = System.TimeSpan.Parse("00:01:00"); binding.OpenTimeout = System.TimeSpan.Parse("00:01:00"); binding.ReceiveTimeout = System.TimeSpan.Parse("00:01:00"); binding.SendTimeout = System.TimeSpan.Parse("00:01:00"); binding.AllowCookies = false; binding.BypassProxyOnLocal = false; binding.HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard; binding.MaxBufferSize = 65536; binding.MaxBufferPoolSize = 524288; binding.MaxReceivedMessageSize = 65536; binding.MessageEncoding = System.ServiceModel.WSMessageEncoding.Text; binding.TextEncoding = System.Text.Encoding.UTF8; binding.TransferMode = System.ServiceModel.TransferMode.Buffered; binding.UseDefaultWebProxy = true; binding.ReaderQuotas.MaxDepth = 32; binding.ReaderQuotas.MaxStringContentLength = 8192; binding.ReaderQuotas.MaxArrayLength = 16384; binding.ReaderQuotas.MaxBytesPerRead = 4096; binding.ReaderQuotas.MaxNameTableCharCount = 16384; binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; binding.Security.Transport.Realm = ""; binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; EndpointAddress endpoint = new EndpointAddress("xxx.com/.../basic"); client = new ExternalWebServiceClient(binding, endpoint); requestInfo = new RMLoginRequestInfo(); requestInfo.DeviceKey = Guid.NewGuid().ToString(); requestInfo.UserName = _userName; requestInfo.Password = _passWord; loginResponse = client.Login(requestInfo); if (loginResponse.IsSuccess) { return "true"; } else { return "false"; }
Many Thanks for any help given!
*This post is locked for comments