[gelöst]Soap ExecuteWorkflowRequest

18. Februar 2014 13:56

Hallo Zusammen,

ich habe eine Funktion, die einen WF aus einem Javascript aufrufen soll.

executeWorkflow = function (wfId, entityId) {
var soapRequest = "<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/'>" + entityId + "</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/'>" + wfId + "</c:value>"
+ "</a:KeyValuePairOfstringanyType>"
+ "</a:Parameters>"
+ "<a:RequestId i:nil='true' />"
+ "<a:RequestName>'ExecuteLeadWorkflow'</a:RequestName>"
+ "</request>"
+ "</Execute>"
+ "</s:Body>"
+ "</s:Envelope>";

var req = new XMLHttpRequest();
req.open("POST", _getClientUrl(), false)
// Responses will return XML. It isn't possible to return JSON.
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
//req.onreadystatechange = function () { SDK.SOAPSamples.assignResponse(req, function (result) { debugger; }, function (result) { debugger; }); };
req.send(soapRequest);

//XrmServiceToolkit.Soap.Execute(soapRequest);


Der SoapRequest ist 1 zu 1 vom Soaplogger kopiert.
Es kommt immer die Fehlermeldung

<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang='en-US'>Request not supported: 'ExecuteLeadWorkflow'</faultstring>
<detail>
<OrganizationServiceFault xmlns='http://schemas.microsoft.com/xrm/2011/Contracts' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<ErrorCode>-2147220715</ErrorCode>
<ErrorDetails xmlns:a='http://schemas.datacontract.org/2004/07/System.Collections.Generic'>
<KeyValuePairOfstringanyType>
<a:key>CallStack</a:key>
<a:value i:type='b:string' xmlns:b='http://www.w3.org/2001/XMLSchema'> at Microsoft.Crm.Caching.SdkMessageRequestCacheLoader.LoadCacheData(SdkMessageRequestKey key, ExecutionContext context)&#xD;\n at Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)&#xD;\n at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)&#xD;\n at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.GetRequestDescription(String requestName, IOrganizationContext context)&#xD;\n at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, UserAuth userAuth, Guid targetUserId, Boolean traceRequest, OrganizationContext context, Boolean returnResponse)&#xD;\n at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)&#xD;\n at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)</a:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<Message>Request not supported: 'ExecuteLeadWorkflow'</Message>
<Timestamp>2014-02-18T11:54:11.6290687Z</Timestamp>
<InnerFault i:nil='true'/>
<TraceText i:nil='true'/>
</OrganizationServiceFault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>


Hat irgendwer eine Idee?

Viele Grüße
Pascal
Zuletzt geändert von pallinio am 18. Februar 2014 15:20, insgesamt 1-mal geändert.

Re: Soap ExecuteWorkflowRequest

18. Februar 2014 15:20

Ich glaube das liegt daran, das ich es Synchron ausgeführt habe.
gleicher Soaprequest mit geänderter Pipeline funktioniert

Code:
            var req = new XMLHttpRequest();
       
            req.open("Post", _getClientUrl(), true);
            // Responses will return XML. It isn't possible to return JSON.
            req.setRequestHeader("Accept", "application/xml, text/xml, */*");
            req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
            req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
            req.onreadystatechange = function () { _assignResponse(req); };       
            req.send(request);
       
    };

    var _assignResponse = function (req) {       
        if (req.readyState == 4) {
            if (req.status != 200) {               
                alert('Workflow not Executed');
                debugger;
            }
        }
    };