2010-07-28 79 views
1

當我嘗試開發CRM的東西,使用下面的代碼:動態CRM 4.0 SOAP異常

「可能的SOAP版本不匹配: 信封

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); 
      } 


     } 

它具有以下例外出現namespace http://schemas.xmlsoap.org/wsdl/ was unexpected。Expectcting http://schemas.xmlsoap.org/soap/envelope/。「

有沒有解決這個問題的方法?

在此先感謝。

回答