我正在尝试从javascript调用CRM操作,但我无法得到回复。我不确定“目标”应该在行动中引用什么。我不知道我的XML是否不正确或我的网址是否有问题。这是我在CRM中的行动
这是我用来调用操作的代码。我看过我的例子,我不知道我错过了什么。
var request = [];
request.push("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">");
request.push("<s:Body>");
request.push("<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\"");
request.push(" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">");
request.push("<request i:type=\"b:AssignRequest\"");
request.push(" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\"");
request.push(" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">");
request.push("<a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">");
request.push("<a:KeyValuePairOfstringanyType>");
request.push("<c:key>Target</c:key>");
request.push("<c:value i:type=\"a:EntityReference\">");
//request.push("<a:Id>" + this._xmlEncode(Target) + "</a:Id>");
request.push("<a:Id>" + entityId + "</a:Id>");
request.push("<a:LogicalName>prostr_project</a:LogicalName>");
request.push("<a:Name i:nil=\"true\" />");
request.push("</c:value>");
request.push("</a:KeyValuePairOfstringanyType>");
request.push("<a:KeyValuePairOfstringanyType>");
request.push("<c:key>TestString</c:key>");
request.push("<c:value i:type=\"a:string\">");
request.push("test");
request.push("</c:value>");
request.push("</a:KeyValuePairOfstringanyType>");
request.push("<a:KeyValuePairOfstringanyType>");
request.push("<c:key>Count</c:key>");
request.push("<c:value i:type=\"a:int\">");
request.push(1);
request.push("</c:value>");
request.push("</a:KeyValuePairOfstringanyType>");
request.push("</a:Parameters>");
request.push("<a:RequestId i:nil=\"true\" />");
request.push("<a:RequestName>mediastr_ProjectTest</a:RequestName>");
request.push("</request>");
request.push("</Execute>");
request.push("</s:Body>");
request.push("</s:Envelope>");
var clientUrl = Xrm.Page.context.getClientUrl();
var requestUrl = clientUrl + "/XRMServices/2011/Organization.svc/web"; //"/MSCRMServices/2007/CrmService.asmx"; //"/XRMServices/2011/Organization.svc?wsdl";
debugger;
var req = new XMLHttpRequest();
req.open("POST", requestUrl, 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 () { SDK.SOAPSamples.assignResponse(req, successCallback, errorCallback); };
var requestXML = request.join("");
req.send(requestXML);
答案 0 :(得分:0)
我建议您重新检查自己使用SoapLogger构建Request Xml。重新检查以下文章 - http://a33ik.blogspot.com/2013/10/custom-actions-walkthrough-for-net-and.html