locked
new CrmService null RRS feed

  • Question

  •  

    Hi,

    I use the :

    http://MyServer:5555/MSCRMServices/2007/CrmServiceWsdl.aspx

    web reference URL using a code that used to work  on another server and other sample codes which I adjust the

    web reference to my server url.

     

    The line:

    CrmService service = new CrmService();

    ends the program with no error. The service is null.

    (token of autentication and organization are also null).

     

    Is this some kind of problem of server  services configuration or code like web reference, appsettings (though I get no

    erros)?

     

    Thanks a lot

    Thursday, October 16, 2008 9:54 AM

Answers

  • Hi,

    Just to clarify. You have something like:

    try
    {

    CrmService service = new CrmService();

    bool suc = false;

    }
    catch(Exception e)
    {
    string x = e.message;
    }

    You're saying the program logic does not catch an error, nor does the 'suc' bool set to false:

    Cheers,

    Karlo

    Thursday, October 16, 2008 6:09 PM

All replies

  • Hi,

    Just to clarify. You have something like:

    try
    {

    CrmService service = new CrmService();

    bool suc = false;

    }
    catch(Exception e)
    {
    string x = e.message;
    }

    You're saying the program logic does not catch an error, nor does the 'suc' bool set to false:

    Cheers,

    Karlo

    Thursday, October 16, 2008 6:09 PM
  • Correct.

    No catching and no init to a variable after the new CrmService.

     

    I use the following code:

     

    private static string CreateAccount(string organizationName, string accountName)
            {                            
                try
                {
                    CrmSdk.CrmService myCrm = new CrmSdk.CrmService();                                                          

     

                    myCrm.Url = GetCrmServiceForOrganization(organizationName);
                    CrmSdk.CrmAuthenticationToken myToken = new CrmSdk.CrmAuthenticationToken();
                    myToken.AuthenticationType = 0;
                    myToken.OrganizationName = organizationName;
                    myCrm.CrmAuthenticationTokenValue = myToken;
                    myCrm.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    CrmSdk.account newAccount = new CrmSdk.account();
                    newAccount.name = accountName;
                    Guid newAccountId = myCrm.Create(newAccount);
                    return newAccountId.ToString();
                }
                catch (System.Web.Services.Protocols.SoapException soapEx)
                {
                    Console.WriteLine("SOAP exception: " + soapEx.Detail.InnerText + "  " + soapEx.ToString());
                    return "SOAP exception: " + soapEx.Detail.InnerText + "  " + soapEx.ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("General exception: " + ex.ToString());
                    return "General exception: " + ex.ToString();
                }
            }// end function;

    Sunday, October 19, 2008 12:12 PM