今天图老师小编给大家展示的是用javascript调用WebService,RetrieveDynamicEntity的方式取出En,精心挑选的内容希望大家多多支持、多多分享,喜欢就赶紧get哦!
【 tulaoshi.com - Web开发 】
function getDynamicEnitity(entityName, entityId,attributeName)
{
var xml = "" +
"?xml version="1.0" encoding="utf-8"?" +
"soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"" + GenerateAuthenticationHeader()+" soap:Body" +
" Execute xmlns="http://schemas.microsoft.com/crm/2007/WebServices"" +
" Request xsi:type="RetrieveRequest" ReturnDynamicEntities="true"" +
" Target xsi:type="TargetRetrieveDynamic"" +
" EntityName"+entityName+"/EntityName" +
" EntityId"+entityId+"/EntityId" +
" /Target" +
" ColumnSet xmlns:q1="http://schemas.microsoft.com/crm/2006/Query" xsi:type="q1:ColumnSet"" +
" q1:Attributes" +
" q1:Attribute"+attributeName+"/q1:Attribute" +
" /q1:Attributes" +
" /ColumnSet" +
" /Request" +
" /Execute" +
" /soap:Body" +
"/soap:Envelope" +
"";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
return resultXml;
}
function getEntityPropertyValue(entityName, entityId,attributeName)
{
var resultXml=getDynamicEnitity("quote",entityId,attributeName);
// Create an XML object to parse the results.
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(resultXml.xml);
var ret=xmlDoc.selectSingleNode("//Property[@Name='"+attributeName+"']");
//ret.text enough for return xml;
//in other case this may not enough be careful for this.
return ret.text;
}
来源:http://www.tulaoshi.com/n/20160219/1610601.html
看过《用javascript调用WebService,RetrieveDynamicEntity的方式取出En》的人还看了以下文章 更多>>