Problem XrmServiceToolkit.Soap.Execute

Jun 25, 2012 at 9:04 AM

Hi ,

I can not convert this request has :

    var xml = "" +
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<soap:Envelope xmlns:soap=\'http://schemas.xmlsoap.org/soap/envelope/\' xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xmlns:xsd=\'http://www.w3.org/2001/XMLSchema\'>" +
    Xrm.Page.context.getAuthenticationHeader() +
    "  <soap:Body>" +
    "    <Execute xmlns=\'http://schemas.microsoft.com/crm/2007/WebServices\'>" +
    "      <Request xsi:type=\"ExecuteWorkflowRequest\">" +
    "        <EntityId>" + entityId + "</EntityId>" +
    "        <WorkflowId>" + workflowId + "</WorkflowId>" +
    "      </Request>" +
    "    </Execute>" +
    "  </soap:Body>" +
    "</soap:Envelope>" +
    "";

the example provided on the site does not help me .


thank you for your help

Coordinator
Jun 26, 2012 at 10:36 AM

Hey There.

You will need to use the correct XML for CRM 2011 to execute a workflow. There are tools in SDK or codeplex to generate the right format XML for CRM 2011 soap request.

Have a look at this link and it should help you to get the XML http://mileyja.blogspot.com/2011/06/execute-workflow-using-net-or-jscript.html

After that, use similar examples as the WhoAmI request to run XrmServiceToolkit.Soap.Execute method. I have just used the XML from the example and modified a bit without testing it. But i would recommend you read through the link and try to generate the request script yourself

  requestMain += "      <request i:type=\"b:ExecuteWorkflowRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
  requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
  requestMain += "          <a:KeyValuePairOfstringanyType>";
  requestMain += "            <c:key>EntityId</c:key>";
  requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + entityId + "</c:value>";
  requestMain += "          </a:KeyValuePairOfstringanyType>";
  requestMain += "          <a:KeyValuePairOfstringanyType>";
  requestMain += "            <c:key>WorkflowId</c:key>";
  requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">" + workflowId + "</c:value>";
  requestMain += "          </a:KeyValuePairOfstringanyType>";
  requestMain += "        </a:Parameters>";
  requestMain += "        <a:RequestId i:nil=\"true\" />";
  requestMain += "        <a:RequestName>ExecuteWorkflow</a:RequestName>";
  requestMain += "      </request>";

Hope this helps.

Thanks,

Jaimie