Ruby和MS Dynamics CRM身份验证

时间:2011-02-10 15:03:36

标签: dynamics-crm dynamics-crm-4

我正在尝试访问通过IFD公开的MS 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>

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

我在尝试以下请求时也获得了401(这次是到CrmService.asmx端点):

<?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 个答案:

答案 0 :(得分: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>

请注意,不需要CallerId元素。

答案 1 :(得分:0)

您可以启用服务器端跟踪by handtool。在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的服务,这将极大地简化非网络产品对CRM Web服务的使用。

相关问题