locked
Create task and add it to a queue with soap crmservice mscrm 3 RRS feed

  • Question

  • Hi,

    We have an external application for our customer contactcenter.

    From this application we want see and change data of our contacts(members) from our backand crm and create tasks and phonecalls in our backend crm (version 3) attached to contacts. We use an enterprise service bus that connects with soap calls to crmservice to our crm 3.

    I can easy create a task with the Create operation, but to assign the task to a queue I think I need to use the Execute operation with a RouteRequest. I tried to translate examples in C# or javascript to soap but I failed to get it working. Can anyone tell me what I am doing wrong?

    Among others I found this example in this forum :

    Assign Task to Queue (Crm 4.0)

    It is CRM 4 but I verified that a similar RouteRequest exist in the WSDL of Crmservice of CRM 3. The essential part of the example is:

    // Create a Target object that refers to the incident.  
                TargetQueuedIncident target = new TargetQueuedIncident();  
                target.EntityId = new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC");  
                target.EntityId = incidentID;  
     
                Route the incident from the WIP queue to the public queue.  
                RouteRequest route = new RouteRequest();  
                route.Target = target;  
                route.RouteType = RouteType.Queue;  
                route.EndpointId = new Guid("A0F2D8FE-6468-DA11-C748-000D9DD8CDAC");  
                route.EndpointId = publicQueueID;  
                route.SourceQueueId = new Guid("A0F2D8FE-6468-DA11-D748-000D9DD8CDAC");  
                route.SourceQueueId = wipQueue.queueid.Value;  
     
                RouteResponse routed = null;  
                routed = (RouteResponse)service.Execute(route);

    I translated that to the following soap message for a task:

          <web:Request xsi:type="RouteRequest">
          <web:Target xsi:type="TargetQueuedTask">
           <web:EntityId>9C19B87F-833A-E411-B5C5-005056B60C7E</web:EntityId>
          </web:Target>
          <web:SourceQueueId>49B617E6-1AAB-DB11-97EA-005056A33D27</web:SourceQueueId>
           <web:RouteType>Queue</web:RouteType>
           <web:EndpointId>5D6D9419-8303-DC11-AE43-005056A33D27</web:EndpointId>
          </web:Request>

    Result is the following error:

    <details>Server was unable to read request.

       at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()

       at System.Web.Services.Protocols.WebServiceHandler.Invoke()

       at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

    There is an error in XML document (7, 8).

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events)

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)

       at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()

    There is an error in XML document (7, 8).

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, XmlDeserializationEvents events)

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)

       at Microsoft.Crm.Sdk.ParserHelper.ParseClrType(ParsingContext context, Type type)

       at Microsoft.Crm.Sdk.ClrTypeParser.Parse(ParsingContext context)

       at Microsoft.Crm.Sdk.RequestParser.Parse(ParsingContext context, RequestDescription requestDescription)

       at Microsoft.Crm.Sdk.Request.ReadXml(XmlReader reader)

       at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)

       at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read20_Execute()

       at Microsoft.Xml.Serialization.GeneratedAssembly.ExecuteSerializer.Deserialize(XmlSerializationReader reader)

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

    &lt;SourceQueueId xmlns='http://schemas.microsoft.com/crm/2006/WebServices'&gt; was not expected.

       at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderGuid.Read2_web_x003A_SourceQueueId()

    Where line 7 character 8 is the start of the  <web:SourceQueueId> tag.

    When I remove this tag I get the message:

    "Invalid format of input XML for request RouteRequest: required field 'SourceQueueId' is missing."

    I have also tried it with incident but this gives the same errors.

    I have also searched the CRM application for callouts with examples of this action and found this:

        if(foundQueue != null && foundCurrentQueue != null)
        {
         // set the task to be queued as the target
         TargetQueuedTask targetTask = new TargetQueuedTask();
         targetTask.EntityId = taskId;

         // route it to the found queue
         RouteRequest route = new RouteRequest();
         route.Target = targetTask;

         route.EndpointId = foundQueue.queueid.Value;
         route.RouteType = RouteType.Queue;

         route.SourceQueueId = foundCurrentQueue.queueid.Value;

         RouteResponse response = (RouteResponse)CrmServiceAgent.Execute(route);


    Friday, September 26, 2014 8:08 AM

Answers

  • In the meantime I found a solution.

    It seems CRM 3 has sometimes problems with namespace-prefixes. When I enter the namespace in the Request tag and I delete all te prefixes web: it works.

    I found the key form my solution on a setState request here:

    http://stackoverflow.com/questions/1739947/required-field-entityid-is-missing-error

    Mij working soap Request message is now:

          <Request xmlns="http://schemas.microsoft.com/crm/2006/WebServices" xsi:type="RouteRequest">
        <Target xsi:type="TargetQueuedTask">
        <EntityId>9C19B87F-833A-E411-B5C5-005056B60C7E</EntityId>
        </Target>
          <SourceQueueId>49B617E6-1AAB-DB11-97EA-005056A33D27</SourceQueueId>
          <RouteType>Queue</RouteType>
          <EndpointId>5D6D9419-8303-DC11-AE43-005056A33D27</EndpointId>
          </Request>

    Tuesday, November 11, 2014 9:22 AM