CRM2011 FetchXml错误 - System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse

时间:2013-09-25 11:46:52

标签: soap dynamics-crm-2011 fetchxml

我有更改服务器,现在我遇到了fechxml的问题,所有其他SOAP服务都在100%工作,比如updade,create,delete,expect fetch,我不知道或者这个原因正在发生。

Mesagem错误:

@"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"

Reference.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;
}

任何人都知道是什么?万分感谢

1 个答案:

答案 0 :(得分:1)

不知道是否还有其他内容,但您在抓取XML中错过了结束</Entity>标记。

修改

想知道你为什么要推出自己的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语句中