动态 CRM 4.0 SOAP 异常
当我尝试开发 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几个小时的研究,我发现问题是由于使用了错误的服务地址造成的。我没有连接到实际地址,而是连接到重定向地址。
所以在上面的代码中,我使用了重定向的地址:
我应该使用以下内容地址:
干杯。
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:
I should have been used the following address:
Cheers.