CRM身份验证问题
CRM Authentication issue
如何在JavaScript中包含GenerateAuthenticationHeader()。我需要包括哪些必要的DLL?我使用这个函数来检索使用JavaScript的MS CRM实体。我得到这个错误:
Microsoft JScript运行时错误:"GenerateAuthenticationHeader"未定义
function AccessCRMWebServices() {
debugger;
var auth = GenerateAuthenticationHeader();
var productCode = "ABCDE";
var stock;
var x = Xrm.Page.getAuthenticationHeader();
var fetchXml = '<fetch version="1.0" output-format="xml-platform" mapping="logical">';
// Target Entity Name
fetchXml += '<entity name="new_aditya_products">';
// Required Attribute
fetchXml += '<attribute name="new_productname"/>';
fetchXml += '<attribute name="new_name"/>';
// Condition
fetchXml += '<filter type="and">';
fetchXml += '<condition attribute="new_productcode" operator="eq" value="' + productCode + '" />';
fetchXml += '</filter>';
fetchXml += '</entity>';
fetchXml += '</fetch>';
var Xml = "<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'">"
Xml += GenerateAuthenticationHeader()
Xml += "<soap:Body>";
Xml += "<Fetch xmlns='"http://schemas.microsoft.com/crm/2007/WebServices'">";
Xml += "<fetchXml>";
//Xml += _HtmlEncode(fetchXml);
Xml += "</fetchXml>";
Xml += "</Fetch>";
Xml += "</soap:Body>";
Xml += "</soap:Envelope>";
var XmlHttp = CreateXmlHttp();
XmlHttp.open("POST", 'http://rxdotnet:5555/MSCRMServices/2007/MetadataService.asmx', false);
XmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
XmlHttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
XmlHttp.send(Xml);
var resultDoc = loadXmlDocument(XmlHttp.responseXML.text);
var resultRecords = resultDoc.selectNodes("//stockvolume");
var resultnames = resultDoc.selectNodes("//new_name");
if (resultRecords.length == 1) {
stock = resultRecords[0].text;
alert('Product ' + resultnames[0].text + ' Contains stock is -' + stock);
}
我假设您使用的是MS CRM 4.0版
GenerateAuthenticationHeader
函数只能从表单代码中本地获得(它是SDK中记录的全局函数)。我认为在任何其他上下文中使用它都是不受支持的。这就是你出错的原因。
根据SDK,它所做的就是创建一个看起来像这样的SOAP头(所以也许你可以在代码中重新创建它):
<soap:Header>
<CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<AuthenticationType xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
0
</AuthenticationType>
<OrganizationName xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
AdventureWorksCycle
</OrganizationName>
<CallerId xmlns="http://schemas.microsoft.com/crm/2007/CoreTypes">
00000000-0000-0000-0000-000000000000
</CallerId>
</CrmAuthenticationToken>
</soap:Header>
除此之外,可能还有其他解决方案。你想做什么?你的代码在哪里运行?
相关文章:
- Sencha Touch和远程服务器上的身份验证
- Javascript清除缓存以清除基本身份验证凭据
- REST的面向公众的身份验证机制
- 当需要身份验证时,ui路由器不会重定向
- CRM身份验证问题
- 获取json结果的身份验证问题
- 在Internet Explorer 11中使用SoundCloud进行身份验证时出现问题
- jQuery,CORS,JSON(不带填充)和身份验证问题
- Facebook标签/页面身份验证问题:getLoginStatus总是返回not_authorized
- 使用 JavaScript 问题使用 LinkedIn API 进行身份验证
- Chrome 的 HTTP BASIC 身份验证注销问题
- MongoError: 身份验证失败.- 连接到MongoLab时出现问题
- 使用基于Java EE表单的身份验证时出现Javascript问题
- 此HTTP Get-Basic身份验证代码有什么问题
- P4身份验证问题
- 身份验证问题
- Firebase匿名身份验证问题
- 使用Everyauth的github身份验证的承诺问题
- Google使用OAuth2身份验证从JavaScript客户端接触API问题
- JsonWebToken用户身份验证问题