CRM 2011/2013 – SoapLogger – SOAP Request aufbauen

Hi Leute,

manchmal kommt man in die Verlegenheit einen SOAP-Request mittels Javascript aufbauen zu müssen. Das kann sich recht mühsam gestalten, z.B. mittels Fiddler.
Im SDK ist ein kleines Tool, der sog. „SoapLogger“, beigelegt.

In diesem Tool kann man wie gewohnt seinen Request, z.B. ExecuteWorkflowRequest, mit C#-Code schreiben und erhält in der Output.txt (im BIN-Verzeichnis) den fertigen Soap Request (und Response).
Ein Beispiel:

Man fügt der Klasse SOAPLogger.cs einfach folgenden Code hinzu:

SoapLoggerOrganizationService slos = new SoapLoggerOrganizationService(serverConfig.OrganizationUri, service, output);
                        
                        //Add the code you want to test here:
                        // You must use the SoapLoggerOrganizationService 'slos' proxy rather than the IOrganizationService proxy you would normally use.
                        ExecuteWorkflowRequest request = new ExecuteWorkflowRequest();
                        request.EntityId = new Guid("{D03006F4-2543-E411-9404-00155D1E15D1}");
                        request.WorkflowId = new Guid("{20D1417A-1DB5-475A-A751-7FF496E7CB7B}");
                        slos.Execute(request);

Ergebnis ist dann folgendes:

HTTP REQUEST
--------------------------------------------------
POST http://crmd-04/Swarovski/XRMServices/2011/Organization.svc/web
Content-Type: text/xml; charset=utf-8
SOAPAction: http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <request i:type="b:ExecuteWorkflowRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts">
        <a:Parameters xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
          <a:KeyValuePairOfstringanyType>
            <c:key>EntityId</c:key>
            <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">d03006f4-2543-e411-9404-00155d1e15d1</c:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <c:key>WorkflowId</c:key>
            <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">20d1417a-1db5-475a-a751-7ff496e7cb7b</c:value>
          </a:KeyValuePairOfstringanyType>
        </a:Parameters>
        <a:RequestId i:nil="true" />
        <a:RequestName>ExecuteWorkflow</a:RequestName>
      </request>
    </Execute>
  </s:Body>
</s:Envelope>
--------------------------------------------------

HTTP RESPONSE
--------------------------------------------------
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <ExecuteResponse xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <ExecuteResult i:type="b:ExecuteWorkflowResponse" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:b="http://schemas.microsoft.com/crm/2011/Contracts">
        <a:ResponseName>ExecuteWorkflow</a:ResponseName>
        <a:Results xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
          <a:KeyValuePairOfstringanyType>
            <c:key>Id</c:key>
            <c:value i:type="d:guid" xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/">00000000-0000-0000-0000-000000000000</c:value>
          </a:KeyValuePairOfstringanyType>
        </a:Results>
      </ExecuteResult>
    </ExecuteResponse>
  </s:Body>
</s:Envelope>
--------------------------------------------------

Cheers,
Christian

Leave a reply