dynamics-crm-2011 - 客户关系管理 2013 : Calling actions from javascript

标签 dynamics-crm-2011 dynamics-crm crm

我尝试使用以下函数从 javascript 调用操作:

function ExecuteActionCreateProject(reason, entityId, entityName, requestName)
{
    // Creating the request XML for calling the Action
    var requestXML = ""
    requestXML += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
    requestXML += "  <s:Body>";
    requestXML += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
    requestXML += "      <request xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\">";
    requestXML += "        <a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
    requestXML += "          <a:KeyValuePairOfstringanyType>";
    requestXML += "            <b:key>Reason</b:key>";
    requestXML += "            <b:value i:type=\"c:string\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\">"+reason+"</b:value>";
    requestXML += "          </a:KeyValuePairOfstringanyType>";
    requestXML += "          <a:KeyValuePairOfstringanyType>";
    requestXML += "            <b:key>Target</b:key>";
    requestXML += "            <b:value i:type=\"a:EntityReference\">";
    requestXML += "              <a:Id>"+entityId+"</a:Id>";
    requestXML += "              <a:LogicalName>"+entityName+"</a:LogicalName>";
    requestXML += "              <a:Name i:nil=\"true\" />";
    requestXML += "            </b:value>";
    requestXML += "          </a:KeyValuePairOfstringanyType>";
    requestXML += "        </a:Parameters>";
    requestXML += "        <a:RequestId i:nil=\"true\" />";
    requestXML += "        <a:RequestName>"+requestName+"</a:RequestName>";
    requestXML += "      </request>";
    requestXML += "    </Execute>";
    requestXML += "  </s:Body>";
    requestXML += "</s:Envelope>";
    var req = new XMLHttpRequest();
    req.open("POST", GetClientUrl(), false)
    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/IOrganizationServic/Execute");
    req.send(requestXML);
    //Get the Resonse from the CRM Execute method
    var response = req.responseXML.xml;
}

我能够成功传递函数参数和客户端 URL,但这是我得到的响应:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <s:Fault>
        <faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</faultcode>
        <faultstring xml:lang="en-US">The message with Action 'http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationServic/Execute' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
        </faultstring>
        </s:Fault>
    </s:Body>
</s:Envelope>

请指教

最佳答案

打字错误!

req.setRequestHeader("SOAPAction", 
"http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationServic/Execute");

“IOrganizationServic”需要附加一个“e”。

你在使用 SOAPLogger 吗?

关于dynamics-crm-2011 - 客户关系管理 2013 : Calling actions from javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20577698/

相关文章:

json - 客户关系管理 2011 : Getting entity with Javascript

dynamics-crm-2011 - 创建 "Split Button"

dynamics-crm - 为什么我的 CRM 工作流程会触发无限循环保护?

javascript - 客户关系管理 2011 : Set datetime field from string with javascript

dynamics-crm-2011 - 使用 Xrm.Utility.openEntityForm 设置查找的文本值

javascript - 选择 XML 中的节点

javascript - CRM 2011 - 如何在 JavaScript 中使用 SOAP 请求检索全局选项集

dynamics-crm - 货币数据类型字段的汇总字段不适用于自定义实体

javascript - 如何使用 javascript 扩展文本字段以消除滚动

javascript - Dynamics crm rest builder 查询多对多关系