Reputation: 155
I have change server and now i'm having a problem with fechxml, all other SOAP services are working 100%, like updade, create, delete, expect fetch, and i don`t have idea or the reason for this to be happening.
Mesagem error:
@"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 file:
[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 file:
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;
}
Any one have an idea of what is? Thanks a million
Upvotes: 0
Views: 833
Reputation: 18895
Don't know if there is something else, but you're missing your closing </Entity>
Tag in your fetch XML.
wondering why you're rolling you're own Fetch SOAP.
Should just be doing something like this:
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));
Also, OrganizationServiceProxy
implements IDisposible
and therefor should be wrapped in a using statement
Upvotes: 1