P
Peter Kenyon
Hi,
I have been attempting to use the CRM web service to retrieve a list of
accounts belonging to the connected user. I am able to do this from my
workstation, but the same code executed on a pocket PC device behaves as if
the query's Criteria and ColumnSet fields have been left null: the query
returns all the accounts I have read access to (ie all on the system) and
only a single attribute for each account (accountid).
I captured the SOAP sessions from my device and there are a few differences:
the device is sending a soap header while the workstation is not, the
namespace is missing from the <Order> element on the device, and the order
of some XML nodes in the soap request is different. I'm not sure which if
any of these should result in the behaviour I'm seeing, and if so what I can
do to change XML generated by the .net compact framework.
Does anybody have any suggestions before I open a support incident? I am
using the .net compact framework 2.0 SP1.
Cheers
Peter
My code below:
CrmService service = new CrmTest.mscrm.CrmService();
service.Credentials = new System.Net.NetworkCredential("Peter", "*******",
"mydomain");
WhoAmIResponse whoAmI = (WhoAmIResponse)service.Execute(new
WhoAmIRequest());
ColumnSet columnSet = new ColumnSet();
columnSet.Attributes = new string[] { "accountnumber", "name",
"address1_name", "address1_line1", "address1_line2", "address1_line3",
"address1_postalcode", "address1_city" };
ConditionExpression conditionExpression = new ConditionExpression();
conditionExpression.AttributeName = "ownerid";
conditionExpression.Operator = ConditionOperator.Equal;
conditionExpression.Values = new object[] { whoAmI.UserId };
FilterExpression filterExpression = new FilterExpression();
filterExpression.FilterOperator = LogicalOperator.And;
filterExpression.Conditions = new ConditionExpression[] {
conditionExpression };
filterExpression.Filters = new FilterExpression[0];
QueryExpression query = new QueryExpression();
query.EntityName = Convert.ToString(EntityName.account);
query.ColumnSet = columnSet;
query.Criteria = filterExpression;
query.Distinct = true;
query.Orders = new OrderExpression[] { new OrderExpression() };
query.Orders[0].AttributeName = "name";
query.Orders[0].OrderType = OrderType.Ascending;
query.PageInfo = new PagingInfo();
query.PageInfo.Count = 50;
query.PageInfo.PageNumber = 1;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;
request.ReturnDynamicEntities = true;
RetrieveMultipleResponse response =
(RetrieveMultipleResponse)service.Execute(request);
I have been attempting to use the CRM web service to retrieve a list of
accounts belonging to the connected user. I am able to do this from my
workstation, but the same code executed on a pocket PC device behaves as if
the query's Criteria and ColumnSet fields have been left null: the query
returns all the accounts I have read access to (ie all on the system) and
only a single attribute for each account (accountid).
I captured the SOAP sessions from my device and there are a few differences:
the device is sending a soap header while the workstation is not, the
namespace is missing from the <Order> element on the device, and the order
of some XML nodes in the soap request is different. I'm not sure which if
any of these should result in the behaviour I'm seeing, and if so what I can
do to change XML generated by the .net compact framework.
Does anybody have any suggestions before I open a support incident? I am
using the .net compact framework 2.0 SP1.
Cheers
Peter
My code below:
CrmService service = new CrmTest.mscrm.CrmService();
service.Credentials = new System.Net.NetworkCredential("Peter", "*******",
"mydomain");
WhoAmIResponse whoAmI = (WhoAmIResponse)service.Execute(new
WhoAmIRequest());
ColumnSet columnSet = new ColumnSet();
columnSet.Attributes = new string[] { "accountnumber", "name",
"address1_name", "address1_line1", "address1_line2", "address1_line3",
"address1_postalcode", "address1_city" };
ConditionExpression conditionExpression = new ConditionExpression();
conditionExpression.AttributeName = "ownerid";
conditionExpression.Operator = ConditionOperator.Equal;
conditionExpression.Values = new object[] { whoAmI.UserId };
FilterExpression filterExpression = new FilterExpression();
filterExpression.FilterOperator = LogicalOperator.And;
filterExpression.Conditions = new ConditionExpression[] {
conditionExpression };
filterExpression.Filters = new FilterExpression[0];
QueryExpression query = new QueryExpression();
query.EntityName = Convert.ToString(EntityName.account);
query.ColumnSet = columnSet;
query.Criteria = filterExpression;
query.Distinct = true;
query.Orders = new OrderExpression[] { new OrderExpression() };
query.Orders[0].AttributeName = "name";
query.Orders[0].OrderType = OrderType.Ascending;
query.PageInfo = new PagingInfo();
query.PageInfo.Count = 50;
query.PageInfo.PageNumber = 1;
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;
request.ReturnDynamicEntities = true;
RetrieveMultipleResponse response =
(RetrieveMultipleResponse)service.Execute(request);