locked
Azure listener is not reading the RemoteExecutionContext Post by CRM azure plugin RRS feed

  • Question

  • Hi Friends,

    We have integrated CRM 2013 on premise with Azure. We are able to post data to service bus queue from CRM using Queue-Contract. But when we tried to get the RemoteExecution Context in the QueueListner we are getting the following error, “there was an error deserializing the object of type Microsoft.Xrm.Sdk.RemoteExecutionContext. The input source is not correctly formatted" on the line receivedMessage.GetBody<RemoteExecutionContext>()“, 

    Below is the sample code we are using.

    <v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"><v:stroke joinstyle="miter"><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"><v:f eqn="sum @0 1 0"><v:f eqn="sum 0 0 @1"><v:f eqn="prod @2 1 2"><v:f eqn="prod @3 21600 pixelWidth"><v:f eqn="prod @3 21600 pixelHeight"><v:f eqn="sum @0 0 1"> </v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas></v:stroke></v:shapetype><v:shape id="_x0000_i1025" style="width:569.25pt;height:161.25pt;" type="#_x0000_t75"><v:imagedata o:title="" src="file:///C:\Users\npi5cob\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png">
    </v:imagedata></v:shape>

    Monday, October 20, 2014 2:40 PM

All replies

  • Im getting the same issue. Did you resolve?
    Tuesday, January 27, 2015 1:29 PM
  • Unfortunately no. We did a workaround by implementing WCF service and posting the data to azure queue from there.
    Tuesday, January 27, 2015 2:22 PM
  • Sorry to be daft, but did you create the wcf service and host as part of a plugin for the CRM and then Broker the message correctly to the bus?
    Tuesday, January 27, 2015 2:51 PM
  • Sorry for the late reply. We deployed WCF service in the CRM server, which will post the data to Azure Queue using BrokeredMessage. We called the wcf service from our plugin.
    Monday, February 23, 2015 11:52 AM
  • I stumbled upon this today as well. The problem is, that the message body does not contain the RemoteExecutionContext directly. Instead it contains a SOAP message with the RemoteExecutionContext in the body. Therefore, I use the following code instead of the whole code above:

    var stream = message.GetBody<System.IO.Stream>();
    using (var reader = new XmlTextReader(stream))
    {
        var soapMessage = System.ServiceModel.Channels.Message.CreateMessage(reader, System.Int32.MaxValue, System.ServiceModel.Channels.MessageVersion.Default);
        RemoteExecutionContext context = soapMessage.GetBody<RemoteExecutionContext>();
    }

    • Proposed as answer by Markus Tobler Tuesday, March 31, 2015 12:24 PM
    Tuesday, March 31, 2015 12:24 PM
  • Wow I got this problem yesterday and now I see that 5 hours ago You answered.

    THIS IS THE Answer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Kudos Markus

    Tuesday, March 31, 2015 6:04 PM
  • I stumbled upon this today as well. The problem is, that the message body does not contain the RemoteExecutionContext directly. Instead it contains a SOAP message with the RemoteExecutionContext in the body. Therefore, I use the following code instead of the whole code above:

    var stream = message.GetBody<System.IO.Stream>();
    using (var reader = new XmlTextReader(stream))
    {
        var soapMessage = System.ServiceModel.Channels.Message.CreateMessage(reader, System.Int32.MaxValue, System.ServiceModel.Channels.MessageVersion.Default);
        RemoteExecutionContext context = soapMessage.GetBody<RemoteExecutionContext>();
    }

    Thank you so much for this...

    However it would be nice if there was an explanation from MS on why... hard to use the demo's LOL when it doesn't work.

    You saved me after 6 hours of scratching my head.

    Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Tuesday, May 5, 2015 10:57 PM
  • Awesome! you solved the problem that MS don't know how to do it! great job!
    Thursday, July 2, 2015 7:28 AM
  • thank you!  very helpful (-:
    Wednesday, July 22, 2015 9:11 PM
  • var receivedMessage = inboundQueueClient.Receive(TimeSpan.MaxValue);
    
                if (receivedMessage.ContentType = "application/msbin1")
                {
                    RemoteExecutionContext context = receivedMessage.GetBody<RemoteExecutionContext>();
                }
                else if (receivedMessage.ContentType = "application/json")
                {
                    //string jsonBody = new StreamReader(receivedMessage.GetBody<Stream>(), Encoding.UTF8).ReadToEnd();
                    RemoteExecutionContext contextFromJSON = receivedMessage.GetBody<RemoteExecutionContext>(
                        new DataContractJsonSerializer(typeof(RemoteExecutionContext)));
                }
                else if (receivedMessage.ContentType = "application/xml")
                {
                    //string xmlBody = new StreamReader(receivedMessage.GetBody<Stream>(), Encoding.UTF8).ReadToEnd();
                    RemoteExecutionContext contextFromXML = receivedMessage.GetBody<RemoteExecutionContext>(
                        new DataContractSerializer(typeof(RemoteExecutionContext)));
                }

    Friday, January 20, 2017 8:47 AM