tags:

views:

37

answers:

1

Hi All,

When I try to develop CRM stuff, using the code below:

 public static  CrmService GetCrmService()
        {
           //Standard CRM setup

            var authenticationToken = new CrmAuthenticationToken();
            //Using the active directory
            authenticationToken.AuthenticationType = 0;
            authenticationToken.OrganizationName = "myorganizationName";

            var crmService = new CrmService();
            crmService.PreAuthenticate = true;
            crmService.UseDefaultCredentials = false;
            crmService.CrmAuthenticationTokenValue = authenticationToken;

            crmService.Credentials = new NetworkCredential("username", "password", "domain");
            crmService.Url = "http://<ourserver>/mscrmservices/2007/CrmServiceWsdl.aspx";

            return crmService;
        }

        public void RetrieveAccount()
        {

            var accountGuid = new Guid("088FFC38-8285-4AF5-8E36-84BAD6B268ED");
            var crmService = GetCrmService();

            //Set the column to return

            var returnedColumns = new ColumnSet();

            returnedColumns.Attributes = new string[] { "name", "telephone1", "customertypecode" };

            try
            {
                var receivedAccount = crmService.Retrieve(EntityName.account.ToString(), accountGuid, returnedColumns) as account;
                if (receivedAccount != null)
                {
                    Debug.WriteLine(string.Format("Name: {0}, Telephone: {1}", receivedAccount.name, receivedAccount.telephone1));
                }

            }
            catch (Exception exception)
            {

                Debug.WriteLine(exception.Message);
            }


        }

It comes up with the following exception:

"Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/."

Is there any solution for this problem ?

Thanks in advance.

A: 

After spending several hours, I have figured out that the problem was occured because of using the wrong service address. Instead of connecting to the actual address, I have connected to a redirected address.

So in the above code, I used the redirected address:

https://servername/MSCrmServices/2007/CrmServiceWsdl.aspx

I should have been used the following address:

https://servername/mscrmservices/2007/crmservice.asmx

Cheers.

DrakeVN