2011-02-10 131 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服務使用。