1
votes

I'm using Microsoft Dynamics CRM 2016 online and trying to use Azure Service Bus relay from custom workflow activity.

I created a custom activity (based on AzureAwareWorkflowActivity from CRM SDK) and registered an endpoint (details below). Workflow execution ends with the following error:

System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: 50200: Bad Gateway, Resource:sb://****.servicebus.windows.net/update*****. TrackingId:b7681665-**** SystemTracker:NoSystemTracker, Timestamp:10/10/2016 2:15:45 PM (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).

Do you know how to fix this problem?

Workflow activity

namespace Microsoft.Crm.Sdk.Samples
{
    /// <summary>
    /// This class is able to post the execution context to the Windows Azure 
    /// Service Bus.
    /// </summary>
    public class AzureAwareWorkflowActivity : CodeActivity
    {
        /// <summary>
        /// This method is called when the workflow executes.
        /// </summary>
        /// <param name="executionContext">The data for the event triggering
        /// the workflow.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

            IServiceEndpointNotificationService endpointService =
                     executionContext.GetExtension<IServiceEndpointNotificationService>();
            endpointService.Execute(ServiceEndpoint.Get(executionContext), context);
        }

        /// <summary>
        /// Enables the service endpoint to be provided when this activity is added as a 
        /// step in a workflow.
        /// </summary>
        [RequiredArgument]
        [ReferenceTarget("serviceendpoint")]
        [Input("Input id")]
        public InArgument<EntityReference> ServiceEndpoint { get; set; }
    }
}

Endpoint

Endpoint configuration

1

1 Answers

0
votes

Problem solved - the reason was insufficient configuration of a service host processing requests from CRM.

It turned out that the size of the message sent from CRM was bigger than allowed. Adding maxReceivedMessageSize is the solution (2147483647 can be changed to more reasonable value):

<bindings>
  <ws2007HttpRelayBinding>
    <binding name="default" maxReceivedMessageSize="2147483647">
    </binding>
  </ws2007HttpRelayBinding>
</bindings>

The service host was written based on the Two-way listener example from the CRM SDK. Unfortunately the sample does not contain this configuration.