SOAP请求中缺少必需的输入字段以激活全局自定义操作

时间:2015-08-05 20:58:44

标签: javascript xml soap microsoft-dynamics dynamics-crm-2015

我正在尝试激活动态2015中的全局自定义操作,该操作将依次激活在其上注册的插件。当我将参数标记为可选时,我可以激活它,然后激活我正在编写的插件。但是,当自定义操作输入参数设置为required时,即使我传递的键值对包含所需字段名称的键和实体逻辑名称的值,它也会抛出错误,说明它未提供。

使用一个必需的输入参数(entityName)设置自定义操作。虽然发送它时存在键值对,但它不会识别它并向后吐出它没有提供它。

正在发送的XML:

        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>entityName</b:key>";
        requestXML += "            <b:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">" + Xrm.Page.data.entity.getEntityName();
        requestXML += "            </b:value>";
        requestXML += "          </a:KeyValuePairOfStringanyType>";
        requestXML += "        </a:Parameters>";
        requestXML += "        <a:RequestId i:nil=\"true\" />";
        requestXML += "        <a:RequestName>new_StartCloning</a:RequestName>";
        requestXML += "      </request>";
        requestXML += "    </Execute>";
        requestXML += "  </s:Body>";
        requestXML += "</s:Envelope>";

        var req = new XMLHttpRequest();

        req.open("POST", util.getBaseUrl()  + "/XRMServices/2011/Organization.svc/web", 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/IOrganizationService/Execute");

        var response = req.send(requestXML);

返回错误消息:

  

s:ClientRequired字段'entityName'缺失-2147220989Required   字段'entityName'是   missing2015-08-05T20:55:26.0627226Z-2147220970System.ArgumentException:   缺少必填字段'entityName'2015-08-05T20:55:26.0627226Z

感谢您阅读此内容哈哈。

1 个答案:

答案 0 :(得分:1)

<a:KeyValuePairOfStringanyType>

应该是

<a:KeyValuePairOfstringanyType>