【问题标题】:Web Service Authentication to Online Federated Dynamics CRM 2013 from Java从 Java 到 Online Federated Dynamics CRM 2013 的 Web 服务身份验证
【发布时间】:2014-03-06 20:17:05
【问题描述】:

我正在开发一个 Java 程序,以通过 Web 服务与 Microsoft Dynamics CRM 2013 在线版本集成。身份验证与本地 IDP 联合,而不是通过 Windows Live。我在查找有关如何完成此操作的文档时遇到问题。我见过的所有非.NET 环境documentation 都没有显示如何在联合设置中完成集成。

是否可以通过 Java 在此身份验证配置中使用 Dynamics CRM Web 服务?如果是这样,任何文档/代码示例都将受到赞赏。

【问题讨论】:

    标签: java soap dynamics-crm dynamics-crm-2013 ws-security


    【解决方案1】:

    根据我的研究,似乎无法使用联合(本地 ADFS)ID 与 Dynamics Web 服务集成。我们使用的 IDP 不响应 WS-Trust RequestSecurityToken,因此我无法检索 SAML。不过,即使我是,this article 也表示无法检索 Dynamics SAML:

    问题在于必须对访问控制服务接受的 XML SOAP 消息进行签名,并且有关如何执行此操作的详细信息在 CRM SDK/身份模型内部。

    由于您无法签署 XML 消息以发送到访问控制服务,因此无法与 CRM 2011 集成。

    文章接着指出,解决方法是创建一个 Microsoft Online ID。就我而言,这是 Office 365 中的云用户。将此用户添加到我的 Dynamics 实例后,我就可以使用问题中链接到的文档中描述的方法。

    为了完整起见,下面是向https://login.microsoftonline.com/RST2.srf发出的SOAP请求示例

    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
        <a:MessageID>urn:uuid:{GENERATE-GUID-HERE}</a:MessageID>
        <a:ReplyTo>
            <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
        </a:ReplyTo>
        <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo4TBVw9fIMZFmc7ZFxBXIcYAAAAAbd1LF/fnfUOzaja8sGev0GKsBdINtR5Jt13WPsZ9dPgACQAA</VsDebuggerCausalityData>
        <a:To s:mustUnderstand="1">https://login.microsoftonline.com/RST2.srf </a:To>
        <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <u:Timestamp u:Id="_0">
                <u:Created>{UTC-TIMESTAMP}</u:Created>
                <u:Expires>{UTC-TIMESTAMP}</u:Expires>
            </u:Timestamp>
            <o:UsernameToken u:Id="uuid-14bed392-2320-44ae-859d-fa4ec83df57a-1">
                <o:Username>{CLOUD-USERNAME}</o:Username>
                <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">{CLOUD-PASSWORD}</o:Password>
            </o:UsernameToken>
        </o:Security>
    </s:Header>
    <s:Body>
        <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
            <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
                <a:EndpointReference>
                    <a:Address>urn:crmna:dynamics.com</a:Address>
                </a:EndpointReference>
            </wsp:AppliesTo>
            <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
        </t:RequestSecurityToken>
    </s:Body>
    </s:Envelope>
    

    替换以下字段:

    • MessageID:随机 GUID
    • 时间戳/已创建ISO-8601 Format 中的当前时间:YYYY-MM-DDThh:mm:ss.sssZ
    • 时间戳/过期:过期时间在ISO-8601 Format: YYYY-MM-DDThh:mm:ss.sssZ
    • 用户名:您的云用户名
    • 密码:您的云端密码

    响应将包含一个 KeyIdentifier 和 2 个 CypherValue 元素。使用这些来为 CRM 的请求构建 SOAP Header。完整代码可以在问题中引用的链接中找到。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-10
      • 1970-01-01
      • 2013-11-27
      相关资源
      最近更新 更多