Web Services Logon Tip

Less than one minute read time.
If you experience difficulty logging on via the web service interface to a CRM Install (that was installed using windows authentication) this can be helped by setting the UseDefaultCredentials flag for the web service client to true.

See highlighted line in the code snippet below.

private static bool LogonToCRMSystem()
{
Write("Please provide the necessary information to Log onto CRM - ");
String userName = ReadUserInput("Please Enter User Name: ");
String passWord = ReadUserInput("Please Enter User Password: ");
String crmInstall = ReadUserInput("Please Enter URL to CRM Install: ");
try
{
binding.Url = crmInstall;
binding.UseDefaultCredentials = true;
SID = binding.logon(userName, passWord);
binding.SessionHeaderValue = new SessionHeader();
binding.SessionHeaderValue.sessionId = SID.sessionid;
return true;
}

catch (SoapException e)
{
Write(e.Message);
if(TryAgain()) // if the wrong password was given allow them to try again.
return LogonToCRMSystem();
}

catch (Exception e)
{
Write(e.Message + "\n" + e.StackTrace);
System.Threading.Thread.Sleep(5000);//give user time to read the message
}

return false;
}

Thanks to my colleagues in Dublin.
Parents
  • The Web Services interface requires that all non string/character fields have the specified parameter set to true. There are different types of data defined in the WSDL this confirms that the data submitted is of the correct type.

    If a field is of type int (etc) your code should have the specified set to true as follows:

    comprecord.customfield = 28;

    comprecord.customfieldSpecified = true;

Comment
  • The Web Services interface requires that all non string/character fields have the specified parameter set to true. There are different types of data defined in the WSDL this confirms that the data submitted is of the correct type.

    If a field is of type int (etc) your code should have the specified set to true as follows:

    comprecord.customfield = 28;

    comprecord.customfieldSpecified = true;

Children
No Data