代码之家  ›  专栏  ›  技术社区  ›  Toan Nguyen

动态CRM 4.0 SOAP异常

  •  1
  • Toan Nguyen  · 技术社区  · 16 年前

    当我尝试开发CRM时,使用下面的代码:

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

    出现以下异常:

    “可能的SOAP版本不匹配: 信封命名空间 http://schemas.xmlsoap.org/wsdl/ 是 出乎意料。期望 http://schemas.xmlsoap.org/soap/envelope/ ."

    这个问题有什么解决办法吗?

    提前谢谢。

    1 回复  |  直到 15 年前
        1
  •  3
  •   Toan Nguyen    16 年前

    花了几个小时后,我发现问题是因为使用了错误的服务地址。我没有连接到实际地址,而是连接到了一个重定向地址。

    所以在上面的代码中,我使用了重定向地址:

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

    我应该使用以下地址:

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

    干杯。

    推荐文章