Web services in other Programming Languages

1 minute read time.
Sage CRM's documentation for SOAP web services contains examples mainly written in C#, but for people who are interested in using other programming languages, the guide also has examples of some typical SOAP messages that we can use.

If you decide to send plain SOAP message over to CRM, it usually takes the following steps:
  1. Use a helper class if required
  2. Declare your destination
  3. Declare your header information
  4. Declare your mesage body
  5. Serialize it into a SOAP "Envelope"
  6. Send the message

The following is an example in PHP. I use a helper class called "NuSOAP" which can be downloaded at this site: http://sourceforge.net/projects/nusoap/ My pages are hosted on an Apache server running Fedora Linux.

First of all, I need to include the helper class:
require_once('nusoap.php');

Declare an instance of the SOAP client (and in this case, defining the destination as well)
$client = new soapclient('http://192.168.2.1/crm/eware.dll/webservices/SOAP');

Add the header information. In this case it will be empty as this is just a logon message. The header is used to store the session ID as we send more messages across to CRM.
$header = '';

Declare our body. The following is the SOAP message for logging on:
$body = 'admin';

Next, serialize it in an envelope, and finally send it off:
$soapMessage = $client->serializeEnvelope($body, $header, array(), 'document','literal');
$result = $client->send($soapMessage, $soapAction);

The following screen shot is an example of logging onto the CRM webservice and obtaining a session ID.













Subsequent SOAP messages (say you want to do a query) will be the same, except this time you will include the session ID in the header instead of leaving it empty. For example:
$header = '3468004660345446';

Note that for hosted version of CRM, the SID includes a check sum which should be included when sending the SOAP message. It looks something like this:
$header = '644354534453454=ASDFWEBSDFDSFLL';