2011-02-10 134 views
1

我试图访问通过IFD公开的MS CRM,并且出现身份验证问题。Ruby和MS Dynamics CRM身份验证

SOAP端点位于NTLM后面,我可以访问它。问题是,路过请求时,像下面的我得到401回复:

<?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"> 
    <soap:Body> 
     <Execute xmlns="http://schemas.microsoft.com/crm/2007/CrmDiscoveryService"> 
      <Request xsi:type="RetrieveCrmTicketRequest"> 
       <OrganizationName>#{CRM_CONFIG[:org_name]}</OrganizationName> 
       <UserId>#{CRM_CONFIG[:username]}</UserId> 
       <Password>#{CRM_CONFIG[:password]}</Password> 
      </Request> 
     </Execute> 
    </soap:Body> 
</soap:Envelope> 

有没有在服务器上调试这个的方法吗?我可以检查任何日志以获取更有意义的错误消息?

<?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\"> 
    <soap:Header> 
    <CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\"> 
     <AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">2</AuthenticationType> 
     <OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{CRM_CONFIG[:org_name]}</OrganizationName> 
     <CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">#{TOUCH}</CallerId> 
    </CrmAuthenticationToken> 
    </soap:Header> 
    <soap:Body> 
    <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\"> 
     <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\"> 
     <q1:EntityName>contact</q1:EntityName> 
     </query> 
    </RetrieveMultiple> 
    </soap:Body> 
</soap:Envelope> 

回答

2

好了,问题是设置的一个误区:

当使用NTLM,Active Directory身份验证时,这意味着CrmAuthenticationToken应该是这个样子的:

<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\">#{CRM_CONFIG[:org_name]}</OrganizationName> 
</CrmAuthenticationToken> 

注意来电显示元素是不需要的。

0

您可以打开服务器端跟踪by hand或用tool

尝试下面的请求时(此时的CrmService.asmx端点)我也得到一个401。在C:\ Program Files \ Microsoft Dynamics CRM \ Trace中查找跟踪文件。为了便于跟踪文件查看,我推荐使用CRM Trace Log Viewer

有很多关于如何call Dynamics CRM web services from JavaScript的文章。我可以想象那些会派上用场。

根据我的经验,另外两个工具也会派上用场,Fiddler跟踪http请求和响应,SoapUI用于Web服务测试和调试。

另请注意,除了基于SOAP之外,Dynamics CRM 2011还将提供基于REST的服务,这将极大地简化非.NET产品中的CRM Web服务使用。