动态 CRM 4.0 SOAP 异常

发布于 2024-09-12 02:12:24 字数 2088 浏览 7 评论 0原文

当我尝试开发 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/。"

有吗这个问题的解决方案?

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人问我粥可暖 2024-09-19 02:12:24

经过几个小时的研究,我发现问题是由于使用了错误的服务地址造成的。我没有连接到实际地址,而是连接到重定向地址。

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

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

我应该使用以下内容地址:

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

干杯。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文