Logon request

This C# example logs on to Sage CRM.

Copy
// An Instance of the web service.
private static WebService binding = null;
// Persistent for the duration of the program, maintain the logon results
private static logonresult SID = null;
private static void LogonToCRMSystem()
{
  try
  {
    HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://cloud.sagecrm.com/myCustomerID/eware.dll/webservices/CRMwebservice.wsdl");
    HttpWebResponse response = (HttpWebResponse) request.GetResponse(); binding = new WebService();
    SID = binding.logon("admin", ""); binding.SessionHeaderValue = new SessionHeader();
    //Persistent SID
    binding.SessionHeaderValue.sessionId = SID.sessionid;
    return true;
  }
  catch (SoapException e)
  {
    Write(e.Message);
  }
  catch (Exception e)
  {
    Write(e.Message + "\n" + e.StackTrace);
  }
}

This is the XML request that Web Services process.

Copy
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <logon xmlns="http://tempuri.org/type">
      <username>admin</username>
      <password />
    </logon>
  </soap:Body>
</soap:Envelope>