It seems like there is a wealth of knowledge on how to connect with, and update Dynamics CRM using the CRM SDK, but much less so when trying to perform the same actions via SOAP / SOAP Client. This blog entry will take you through the steps to do just that with a well-known open source tool called SOAPUI.
The first thing you are going to want to do is to download and install the latest version of SOAP UI, which can be found here: http://www.soapui.org/ . Once this has been installed, you will want to grab the CRM .wsdl from your installation of CRM, which can be downloaded from the ‘Organization Service’ link under ‘Customizations / Developer Resources’. Now you should be ready to create a new SOAP UI project, by consuming the .wsdl you just downloaded.
Open SOAP UI, and select ‘New Project’ from the File menu. In the ‘New SOAP Project window’, add a project name and open the organization.wsdl you just downloaded.
Open New SOAP based Project in workspace
At this point SOAP UI will consume the organization.wsdl and create a bunch of web-call templates. So, now the real fun begins….
The first thing I will typically do with a new SOAP UI project is to test the connection with a very simple ‘RETRIEVE’ query, but there are a couple of items we need to setup beforehand.
Add Headers to SOAP-Call
The first thing you will want to do is to add 3 headers to the SOAP call. You can do this by expanding the Headers section on the bottom of the screen, and then by clicking on the ‘+’ icon to add each of the following headers. (For this call, we are going to perform a simple RETRIEVE, so we will use ‘Retrieve’ as our action, but this would change depending on the action we want to use)
add 3 headers to the SOAP call: SOAPAction, Content Type and Accept
Update the URL
Next, you will want to ensure the URL is https (if you are using secure sockets), and to verify you are using the correct port. If you are using standard port 8080 for http, or 443 for https you will not need the port number in the URL, but I have left it in for the sake of this example.
The final update to the URL will be to add the “/web” to the end. If you forget this step, you will most likely get the following error:
“The server cannot service the request because the media type is unsupported.”
Add Authentication Information
Under the Request Properties window, you will want to add username, password, domain and authentication type. Username should NOT be fully qualified since we are adding the domain in a separate field. For this example we are using NTLM authentication type.
Add username, password, domain and authentication type to Request Properties window
The Query / web-call:
Now you can write the web-call. In this case, we are going to query the CONTACT entity with a known guid of a particular contact id. For the sake of simplicity, we will only return the ‘telephone1’ field as proof we can make a successful connection to CRM, and retrieve data. Here is the XML:
return the ‘telephone1’ field and retrieve data
If all goes well, you will get a response from CRM that looks something like this:
Response from CRM
That’s it; a quick simple tool to allow you to start testing your SOAP calls with very little effort. Send me your feedback and let me know how this works out for you. I can always update the post to add more examples for Create, Update, Execute, Delete and RetrieveMultiple actions.