Logon / Logoff using Web Service in Sage CRM

If you have used 'Add Service Reference' to connect to a Sage CRM with VS2008 then you will be using the WebServiceSoapPort class. Before beginning with the development firstly add reference to the web service by simply right clicking the project solution explorer and then Add Service Reference. The below window appears and put you reference URL.

How to Logon using Web Service in Sage CRM and Add Service Reference?

 

Log on (WebServiceSoapClient)

WebServiceSoapPort SageCRMService = new WebServiceSoapPortClient();
logonRequest objLogonRequest = new logonRequest();

//Set your CRM Username and Password
objLogonRequest .username = "CRMAdminUser";
objLogonRequest .password = "yourCrmPassword";
logonResponse objLogonResponse = SageCRMService .logon(objLogonRequest );

SessionHeader objSessionHeader = new SessionHeader();
objSessionHeader.sessionId = objLogonResponse .result.sessionid;

Log off (WebServiceSoapClient)

logoffRequest objLogoffRequest = new logoffRequest();

objLogoffRequest .SessionHeader = objSessionHeader;
objLogoffRequest .sessionId=objLogonResponse .result.sessionid;
logoffResponse objLogoff = SageCRMService.logoff(objLogoffRequest);

By implementing in code as above you will be able to Logon and LogOff in SageCRM. The steps are pretty simple to use but make sure that the logon user must have Web Service access and CRM Web Services are setup.

 


Sapnep IT Solution

We Provide IT solutions and services to deliver a unique blend of real-business experience with a strong engineering, international project delivery. We are a software development  firm.