我需要将一些链接实体添加到 Dynamics 365 CRM 上的 SOAP 查询(它报告的版本是Version 1612 (8.2.1.176) (DB 8.2.1.176)
)。客户端实现是在 PHP 中。
通过一些反复试验和大量示例,我已经能够整理出类似于以下请求正文的内容。(我不确定这是否是构建查询的最佳方式;似乎还有其他几个方法,包括<fetch>
,但到目前为止这个方法已经奏效。)
<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:si="http://www.w3.org/2001/XMLSchema-instance">
<request xmlns:c="http://schemas.microsoft.com/xrm/2011/Contracts" si:type="c:RetrieveMultipleRequest">
<c:Parameters xmlns:c2="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<c:KeyValuePairOfstringanyType>
<c2:key>Query</c2:key>
<c2:value si:type="c:QueryExpression">
<c:ColumnSet>
<c:AllColumns>true</c:AllColumns>
<c:Columns/>
</c:ColumnSet>
<c:EntityName>entity1</c:EntityName>
<c:LinkEntities>
<c:LinkEntity>
<c:LinkFromAttributeName>entity2id</c:LinkFromAttributeName>
<c:LinkFromEntityName>entity1</c:LinkFromEntityName>
<c:LinkToAttributeName>entity2id</c:LinkToAttributeName>
<c:LinkToEntityName>entity2</c:LinkToEntityName>
<c:JoinOperator>Inner</c:JoinOperator>
<c:LinkEntities>
<c:LinkEntity>
<c:LinkFromAttributeName>entity3id</c:LinkFromAttributeName>
<c:LinkFromEntityName>entity2</c:LinkFromEntityName>
<c:LinkToAttributeName>entity3id</c:LinkToAttributeName>
<c:LinkToEntityName>entity3</c:LinkToEntityName>
<c:JoinOperator>Inner</c:JoinOperator>
</c:LinkEntity>
</c:LinkEntities>
</c:LinkEntity>
</c:LinkEntities>
<c:Orders>
<c:OrderExpression>
<c:AttributeName>name</c:AttributeName>
<c:OrderType>Ascending</c:OrderType>
</c:OrderExpression>
</c:Orders>
<c:PageInfo>
<c:Count>1</c:Count>
<c:PageNumber>1</c:PageNumber>
</c:PageInfo>
</c2:value>
</c:KeyValuePairOfstringanyType>
</c:Parameters>
<c:RequestName>RetrieveMultiple</c:RequestName>
</request>
</Execute>
(在这种情况下,从 entity1 到 entity2 的关系似乎是 1:n,从 entity2 到 entity3 的关系似乎是 n:1。实际上,entity2 仅包含用于连接 entity1 和 entity3 的外键,以及一些额外的属性。)
这个查询显然是正确执行的(它运行没有错误,它根据内部连接限制结果集),但我只从第一个实体类型中获取列。
我如何实际获取连接实体的属性?
编辑:
我尝试将以下各项添加到<c:LinkEntity>
元素中:
<c:ColumnSet>
<c:AllColumns>true</c:AllColumns>
</c:ColumnSet>
<c:Columns>
<c:AllColumns>true</c:AllColumns>
</c:Columns>
<c:Columns>
<a:string xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
attribute1
</a:string>
</c:Columns>
<c:ColumnSet>
<c:Columns>
<a:string xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
attribute1
</a:string>
</c:Columns>
</c:ColumnSet>
不幸的是,虽然这些都没有导致错误,但它们也没有改变输出。