在从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服务的替代方案的建议。谁能帮我?谢谢!
答案 0 :(得分:1)
尝试
var xHReq = new XMLHttpRequest();
它也适用于IE7 +