As we already know that Sage CRM’s Web Service API (application programming interface) enables developers to manipulate CRM records remotely with SOAP (Simple Object Access Protocol) over HTTP using XML (Extensible Markup Language). It is possible to access a CRM server or a hosted system from a specified client machine in order to read, create, update, or delete records for Companies, People, Opportunities, or Cases.
The main steps involved in communicating with the Sage CRM Web Service involve The user then accesses the WSDL file from the client and prepares the request. The client machine passes the request with its parameters to the Web Service. The Web Service processes the request and sends a response to the client. The client receives the response synchronously, and it processes the data returned or it deals with the error.
In order to read/write any records in SageCRM you first have to connect to the SageCRM system. The below example illustrates how we can do that.
private static void LogonToCRMSystem()
{
try
{
SID = binding.logon(“admin”, “”);
binding.SessionHeaderValue = new SessionHeader();
binding.SessionHeaderValue.sessionId = SID.sessionid; //Persistent SID
return true;
}
catch (SoapException e)
{
Write(e.Message);
}
catch (Exception e)
{
Write(e.Message + “n” + e.StackTrace);
}
}
Here if you notice we have to pass the SageCRM user name and password in order to login to SageCRM using web service. But can you login via web services without a user name and password!!! Yes you can. But for this you need to know something else. The SageCRM’s active session id and URL, of course. If you know the session id then you can even use as a substitute for COM API. Here is how you do it.
private static void LogonToCRMSystem()
{
try
{
binding.Url = getWsUrl(url);
//assign the session id
binding.SessionHeaderValue.SessionHeaderValue = new SessionHeader();
binding.SessionHeaderValue.sessionId = sessionId;
return true;
}
catch (SoapException e)
{
Write(e.Message);
}
catch (Exception e)
{
Write(e.Message + “n” + e.StackTrace);
}
}