【问题标题】:CRM2011 FetchXml Error - System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponseCRM2011 FetchXml 错误 - System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse
【发布时间】:2013-09-25 11:46:51
【问题描述】:

我有更改服务器,现在我遇到了 fechxml 问题,所有其他 SOAP 服务都在 100% 工作,例如更新、创建、删除、期望获取,我不知道或不知道这样做的原因正在发生。

消息错误:

@"Server was unable to process request.
       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at ws.CrmService.CrmService.Fetch(String fetchXml) in c:\CRMServer\ws\ws\Web References\CrmService\Reference.cs:line 180
       at wsService.Crm2013test(String nomechave) in c:\CRMServer\ws\ws\test\test2013.cs:line 416"

参考.cs 文件:

[System.Web.Services.Protocols.SoapHeaderAttribute("CorrelationTokenValue")]
[System.Web.Services.Protocols.SoapHeaderAttribute("CrmAuthenticationTokenValue")]
[System.Web.Services.Protocols.SoapHeaderAttribute("CallerOriginTokenValue")]         [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://schemas.microsoft.com/crm/2007/WebServices/Fetch",
 RequestNamespace="http://schemas.microsoft.com/crm/2007/WebServices",
 ResponseNamespace="http://schemas.microsoft.com/crm/2007/WebServices",
 Use=System.Web.Services.Description.SoapBindingUse.Literal,
 ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string Fetch(string fetchXml) {
    object[] results = this.Invoke("Fetch", new object[] {fetchXml});
    return ((string)(results[0]));
}

test2013 文件:

 public PrxActivityResult Crm2013test(string nomechave)

{
    PrxActivityResult res = new PrxActivityResult();
    Tb_Log_Create("WS.Crm2013test", "Entrada", "Codigo; valor:" + nomechave, "Anónimo");


    try
    {

        OrganizationServiceProxy organizationProxy = CrmServiceManager.GetOrganisationServiceProxy();
        CrmService service = CrmServiceManager.GetCrmService();

        Microsoft.Xrm.Sdk.Query.ConditionExpression condition = new Microsoft.Xrm.Sdk.Query.ConditionExpression("name", Microsoft.Xrm.Sdk.Query.ConditionOperator.Like, new string[] { nomechave });

        Microsoft.Xrm.Sdk.Query.FilterExpression filter = new Microsoft.Xrm.Sdk.Query.FilterExpression();
        filter.AddCondition(condition);
        filter.FilterOperator = Microsoft.Xrm.Sdk.Query.LogicalOperator.And;

        Microsoft.Xrm.Sdk.Query.QueryExpression query = new Microsoft.Xrm.Sdk.Query.QueryExpression();
        query.EntityName = "account";
        query.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet(true);
       // query.Criteria = filter;

        EntityCollection ec = organizationProxy.RetrieveMultiple(query);

        string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
            <entity name='account'>
            <attribute name='name'/>
            <attribute name='telephone1'/>
            </entity></fetch>";

        string ret = service.Fetch(fetchXml);
        res.XmlContent = ret;

        }


    catch (Exception ex)
    {
    }
    return res;
}

有人知道是什么吗?谢谢一百万

【问题讨论】:

  • 您能否通过写result.XmlContent = return; 来解释您要做什么?我认为您甚至不能通过使用保留关键字作为变量名来构建此代码。
  • 嗨 Scorpion,问题不存在,result.XmlContent = return 好的,问题是当执行 service.Fetch(fetchXml) 时给我异常。 result.XmlContent = return 它将返回给我的 xml 内容。

标签: soap dynamics-crm-2011 fetchxml


【解决方案1】:

不知道是否还有其他内容,但您在提取 XML 中缺少结束 &lt;/Entity&gt; 标记。

编辑

想知道你为什么要滚动你自己的 Fetch SOAP。

应该只是做这样的事情:

string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
    <entity name='account'>
    <attribute name='name'/>
    <attribute name='telephone1'/>
</fetch>";

EntityCollection ec = organizationProxy.RetrieveMultiple(new FetchExpression(fetchXml));

另外,OrganizationServiceProxy 实现了IDisposible,因此应该包含在 using 语句中

【讨论】:

  • 嗨,达里尔,是的,它不见了,但我在复制和粘贴时失败了,但即使使用 &lt;/Entity&gt; 也不起作用!
  • @HugoSilva 修复您的帖子,然后查看更新的答案。 string return = service.Fetch(fetchXml); 不适合我。
  • 它工作正常,我可以获得信息但现在我可以将结果放在字符串上吗?示例:abs1232 ?这是我过去所拥有的,它有效,我真的不知道为什么不再有效。
  • @HugoSilva 您始终可以将实体序列化回来,或者根据属性集合生成您自己的 XML。或者提出一个新问题,“如何将 FetchXML 的结果作为 XML 而不是实体访问?”
猜你喜欢
  • 2012-02-29
  • 2012-03-20
  • 2011-06-22
  • 2017-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多