简体   繁体   English

使用ActiveX调用XRM Javascript调用Web服务的替代方法

[英]Alternative to XRM Javascript calling webservice using ActiveX

I have a problem on CRM javascript when calling a webservice from browsers other than IE. 从IE以外的浏览器调用Web服务时,我在CRM javascript上遇到问题。 See my code below for the web service call implementation. 有关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;
}

There's a problem on this line: 这条线上有一个问题:

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

It runs correctly on IE because it can use ActiveXObject but unfortunately it fails on Firefox/Chrome. 它可以在IE上正确运行,因为它可以使用ActiveXObject,但不幸的是,它在Firefox / Chrome上无法运行。 I'm looking for suggestions on an alternative of calling the web service. 我正在寻找有关替代Web服务的建议。 Can anyone help me? 谁能帮我? Thanks! 谢谢!

try with 尝试

var xHReq = new XMLHttpRequest();

it works also for IE7+ 它也适用于IE7 +

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM