Dynamics CRM 2011 SOAP RetrieveMultiple查询忽略标准

时间:2013-08-01 04:47:03

标签: php soap dynamics-crm-2011

我使用PHP和SOAP连接到Dynamics CRM 2011 Online并遇到了一个问题。以下RetrieveMultiple忽略我的条件并返回所有记录。

我想要的是任何以'test@test.com'作为他们的电子邮件地址的联系人。

有人可以告诉我下面的条件/条件有什么问题吗?

谢谢!

<RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
   <query xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" i:type="b:QueryExpression">
      <b:ColumnSet>
         <b:AllColumns>false</b:AllColumns>
         <b:Columns xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
            <c:string>firstname</c:string>
         </b:Columns>
      </b:ColumnSet>
      <b:Criteria>
         <b:Conditions>
            <b:Condition>
               <b:AttributeName>emailaddress1</b:AttributeName>
               <b:Operator>Equal</b:Operator>
               <b:Values>
                  <b:Value i:type="xsd:string">test@test.com</b:Value>
               </b:Values>
            </b:Condition>
         </b:Conditions>
         <b:FilterOperator>And</b:FilterOperator>
         <b:Filters />
      </b:Criteria>
      <b:Distinct>false</b:Distinct>
      <b:EntityName>contact</b:EntityName>
      <b:LinkEntities />
      <b:PageInfo>
         <b:Count>250</b:Count>
         <b:PageNumber>1</b:PageNumber>
         <b:PagingCookie i:nil="true" />
         <b:ReturnTotalRecordCount>false</b:ReturnTotalRecordCount>
      </b:PageInfo>
   </query>
</RetrieveMultiple>

2 个答案:

答案 0 :(得分:4)

尝试使用以下SOAP格式:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <request i:type="a:RetrieveMultipleRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
        <a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
          <a:KeyValuePairOfstringanyType>
            <b:key>Query</b:key>
            <b:value i:type="a:QueryExpression">
              <a:ColumnSet>
                <a:AllColumns>false</a:AllColumns>
                <a:Columns xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                  <c:string>firstname</c:string>
                </a:Columns>
              </a:ColumnSet>
              <a:Criteria>
                <a:Conditions>
                  <a:ConditionExpression>
                    <a:AttributeName>emailaddress1</a:AttributeName>
                    <a:Operator>Equal</a:Operator>
                    <a:Values xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                      <c:anyType i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">abc@a.com</c:anyType>
                    </a:Values>
                  </a:ConditionExpression>
                </a:Conditions>
                <a:FilterOperator>And</a:FilterOperator>
                <a:Filters />
                <a:IsQuickFindFilter>false</a:IsQuickFindFilter>
              </a:Criteria>
              <a:Distinct>false</a:Distinct>
              <a:EntityName>contact</a:EntityName>
              <a:LinkEntities />
              <a:Orders />
              <a:PageInfo>
                <a:Count>0</a:Count>
                <a:PageNumber>0</a:PageNumber>
                <a:PagingCookie i:nil="true" />
                <a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>
              </a:PageInfo>
              <a:NoLock>false</a:NoLock>
            </b:value>
          </a:KeyValuePairOfstringanyType>
        </a:Parameters>
        <a:RequestId i:nil="true" />
        <a:RequestName>RetrieveMultiple</a:RequestName>
      </request>
    </Execute>
  </s:Body>
        </s:Envelope>

顺便说一句。您可以使用位于SDK \ samplecode \ cs \ client \ soaplogger中的SOAPLogger来获取正确的SOAP表达式。

答案 1 :(得分:3)

上述查询存在一些问题。 (特别是我的一些别名混淆了)。正如Jeff Xiong所建议的那样,SOAPLogger帮助了我。

标准也不正确。下面的工作肥皂:

<RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
   <query xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" i:type="b:QueryExpression">
      <b:ColumnSet>
         <b:AllColumns>false</b:AllColumns>
         <b:Columns xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
            <c:string>firstname</c:string>
            <c:string>emailaddress1</c:string>
         </b:Columns>
      </b:ColumnSet>
      <b:Criteria>
         <b:Conditions>
            <b:ConditionExpression>
               <b:AttributeName>emailaddress1</b:AttributeName>
               <b:Operator>Equal</b:Operator>
               <b:Values xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                  <c:anyType xmlns:d="http://www.w3.org/2001/XMLSchema" i:type="d:string">test@test.com</c:anyType>
               </b:Values>
            </b:ConditionExpression>
         </b:Conditions>
         <b:FilterOperator>And</b:FilterOperator>
         <b:Filters />
      </b:Criteria>
      <b:Distinct>false</b:Distinct>
      <b:EntityName>contact</b:EntityName>
      <b:LinkEntities />
      <b:PageInfo>
         <b:Count>250</b:Count>
         <b:PageNumber>1</b:PageNumber>
         <b:PagingCookie i:nil="true" />
         <b:ReturnTotalRecordCount>false</b:ReturnTotalRecordCount>
      </b:PageInfo>
   </query>
</RetrieveMultiple>