1

从 IE 以外的浏览器调用 Web 服务时,我在 CRM javascript 上遇到问题。有关 Web 服务调用实现,请参见下面的代码。

function RetrieveMultipleEntity(targetEntity, conditionAttributeName, conditionAttributeValue, targetId, targetAttribute)
{
// Prepare variables to retrieve the contacts.
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
// var xml = (the SOAP message)

var xHReq = new ActiveXObject("Msxml2.XMLHTTP");

xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

return resultXml;
}

这一行有一个问题:

var xHReq = new ActiveXObject("Msxml2.XMLHTTP");

它可以在 IE 上正确运行,因为它可以使用 ActiveXObject,但不幸的是它在 Firefox/Chrome 上失败了。我正在寻找有关调用 Web 服务的替代方法的建议。谁能帮我?谢谢!

4

1 回答 1

1

尝试

var xHReq = new XMLHttpRequest();

它也适用于 IE7+

于 2013-03-26T09:00:11.053 回答