Wednesday, December 28, 2011

Calling Microsoft CRM 2011 Web Services from SoapUI

I will assume you are very familiar with SoapUI and have at least a basic understanding of the MS-CRM 2011 WCF interface. I also assume you are using NTLM to authenticate
(the next part of my journey will be see if i can get WS-Security to work).

1) Import the WSDL from the CRM Server: Start a new SoapUI project and get the wsdl from:
http://your_box_name:yourport/your_crm_context_root/XRMServices/2011/Organization.svc?wsdl=wsdl0

2) I chose just a simple Retrieve operation to get back a single Contact. I changed the stub XML request from:





<!--
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:con="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
   <soap:Header/>
   <soap:Body>
      <ser:Retrieve>
         <!--Optional:-->
         <ser:entityName>?</ser:entityName>
         <!--Optional:-->
         <ser:id>?</ser:id>
         <!--Optional:-->
         <ser:columnSet>
            <!--Optional:-->
            <con:AllColumns>?</con:AllColumns>
            <!--Optional:-->
            <con:Columns>
               <!--Zero or more repetitions:-->
               <arr:string>?</arr:string>
            </con:Columns>
         </ser:columnSet>
      </ser:Retrieve>
   </soap:Body>
</soap:Envelope>

-->


To:



<!--
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:con="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
   <soap:Body>
      <ser:Retrieve>
         <ser:entityName>contact</ser:entityName>
         <ser:id>c3d945f0-9824-e111-b825-005056a30027</ser:id>
         <ser:columnSet>
            <con:AllColumns>false</con:AllColumns>
        <con:Columns>
        <arr:string>fullname</arr:string>
        </con:Columns>
         </ser:columnSet>
      </ser:Retrieve>
   </soap:Body>
</soap:Envelope>

-->


You will notice i had to change the soap envelope from the default generated: "http://www.w3.org/2003/05/soap-envelope" to "http://schemas.xmlsoap.org/soap/envelope/"



3) Enter the following HTTP request headers into SoapUI:





SOAPAction http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Retrieve
Accept application/xml, text/xml, */*
Content-Type text/xml; charset=utf-8















4) Set your endpoint to: http://your_box_name_and_port/your_crm_context_root/XRMServices/2011/Organization.svc/web

You should get some data back.

If you get a "bad request", check your SOAP Message.

If you get a "The server cannot service the request because the media type is unsupported.", check your Content-Type.

8 comments:

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi,

This blog has been great help for me to connect CRM 2011 online from SoapUi.

I have followed all your instructions to connect to CRM 2011. However i get response as "Access is Denied". Any idea about the above error or where to specify the security details in SOAP Request


Reponse Suppose message

"


a:FailedAuthentication
Access is denied.


"

Help is greatly appreciated.

Thanks,
Muni

Unknown said...

Hi,

This blog has been great help for me to connect CRM 2011 online from SoapUi.

I have followed all your instructions to connect to CRM 2011. However i get response as "Access is Denied". Any idea about the above error or where to specify the security details in SOAP Request


Reponse Suppose message




a:FailedAuthentication
Access is denied.




Help is greatly appreciated.

Thanks,
Muni

Unknown said...

Auth tab under the request block,
you need to add user/pass/domain for your CRM server

Unknown said...

Hi Steve,
Thanks for the reply.

I tried giving user name /paddword /domain at auth tab but no luck ( same errors )

Regards
Muni

Mr.Pradip Kumbhar said...
This comment has been removed by the author.
Mr.Pradip Kumbhar said...
This comment has been removed by the author.
Anonymous said...

Hello,
i'm testing a CRM2011 On Premise, and the response i receive is correct but contains no crm data, onñy the security Token and "Script is disabled. Click Submit to continue." message.

Any ideas?

Best