lamarvannoy lamarvannoy - 1 month ago 13
Java Question

Web Service Authentication to Online Federated Dynamics CRM 2013 from Java

I am working on a Java program to integrate via web services with a Microsoft Dynamics CRM 2013 online version. Authentication is federated with a local IDP, not through Windows Live. I am having problems finding documentation on how to complete this. All of the non-.NET environment documentation I have seen does not show how to complete the integration in a Federated set-up.

Is it possible to consume Dynamics CRM web services in this authentication configuration from Java? If so, any documentation/code samples are appreciated.


Based on my research, it does not seem possible to integrate with Dynamics web services using a federated (local ADFS) ID. The IDP we are using does not respond to WS-Trust RequestSecurityToken and so I was unable to retrieve the SAML. Even if I was, though, this article suggests that it would not be possible to retrieve the Dynamics SAML:

The issue is that the XML SOAP message that access control service accepts has to be signed and the detail on how to do that is internal to the CRM SDK/Identity Model.

Since you can’t sign the XML message to send to the access control service, integration with CRM 2011 cannot work.

The article goes on to state that the workaround is to have a Microsoft Online ID created. In my case, this is a cloud user within Office 365. Once this user was added to my Dynamics instance, I was able to use the method described in the documentation linked to in the question.

For completeness sake, below is an example of the SOAP request made to

<s:Envelope xmlns:s="" xmlns:a="" xmlns:u="">
    <a:Action s:mustUnderstand="1"></a:Action>
    <VsDebuggerCausalityData xmlns="">uIDPo4TBVw9fIMZFmc7ZFxBXIcYAAAAAbd1LF/fnfUOzaja8sGev0GKsBdINtR5Jt13WPsZ9dPgACQAA</VsDebuggerCausalityData>
    <a:To s:mustUnderstand="1"> </a:To>
    <o:Security s:mustUnderstand="1" xmlns:o="">
        <u:Timestamp u:Id="_0">
        <o:UsernameToken u:Id="uuid-14bed392-2320-44ae-859d-fa4ec83df57a-1">
            <o:Password Type="">{CLOUD-PASSWORD}</o:Password>
    <t:RequestSecurityToken xmlns:t="">
        <wsp:AppliesTo xmlns:wsp="">

Replace the following fields:

  • MessageID: random GUID
  • Timestamp/Created: current time in ISO-8601 Format: YYYY-MM-DDThh:mm:ss.sssZ
  • Timestamp/Expires: expires time in ISO-8601 Format: YYYY-MM-DDThh:mm:ss.sssZ
  • Username: your cloud username
  • Password: your cloud password

The response will contain a KeyIdentifier and 2 CypherValue elements. Use these to construct the SOAP Header for requests to the CRM. Full code can be found in the link referenced in the question.