2013-07-21 136 views
0

我正在嘗試在Microsoft Dynamic 2011中創建一個潛在客戶。我已將我的PHP腳本連接到CRM,並獲得了積極的反饋。通過PHP向CRM2011發送SOAP請求

我已經使用Fiddler獲取用於在CRM2011中創建潛在顧客的肥皂代碼。但是,當我通過我的PHP腳本使用相同的代碼時,我會返回'​​false'。

,我已經發現了肥皂代碼如下:

<s:Body> 
     <Execute xmlns="http://schemas.microsoft.com/crm/2009/WebServices"> 
       <command>1</command> 
       <commandXml> 
        <Input> 
         <id>{00000000-0000-0000-0000-000000000000}</id> 
         <name>lead</name> 
         <formId>e3b6ddb7-8df0-4410-ac7b-fd32e5053d38</formId> 
         <dataxml> 
          <lead> 
           <leadqualitycode>2</leadqualitycode> 
           <statuscode>1</statuscode> 
           <ownerid type="8" name="Vlad Hercules">{6710C3A0-6EE9-E211-B17C-984BE16D3DAA}</ownerid> 
           <decisionmaker>0</decisionmaker> 
           <salesstage>0</salesstage> 
           <subject>subject</subject> 
           <lastname>vladislav</lastname> 
           <transactioncurrencyid type="9105" name="usd">{5B1C0B98-6CE9-E211-8B44-984BE17C9A7B}</transactioncurrencyid> 
           <preferredcontactmethodcode>1</preferredcontactmethodcode> 
           <donotemail>0</donotemail> 
           <donotbulkemail>0</donotbulkemail> 
           <donotphone>0</donotphone> 
           <donotpostalmail>0</donotpostalmail> 
           <donotsendmm>0</donotsendmm> 
          </lead> 
         </dataxml> 
         <associations></associations> 
        </Input> 
       </commandXml> 
      </Execute> 
     </s:Body> 
    </s:Envelope> 

如何這個問題得到解決?我可以在哪裏獲得關於請求的外觀的信息?

這是由微軟提供的示例返回假的,當我嘗試了:

<Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"> 
        <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
         <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
          <b:KeyValuePairOfstringanyType> 
           <c:key>name</c:key> 
           <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Newer Corporation</c:value> 
          </b:KeyValuePairOfstringanyType> 
         </b:Attributes> 
         <b:EntityState i:nil="true"/> 
         <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/> 
         <b:Id>00000000-0000-0000-0000-000000000000</b:Id> 
         <b:LogicalName>account</b:LogicalName> 
         <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/> 
        </entity> 
        </Create> 

回答

1

我不完全在CRM2011 SOAP的專家呼籲,所以我還沒有看到這種類型的查詢之前,不過,我想建議您嘗試使用類似於以下內容的內容。

<Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <entity xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts"> 
     <a:Attributes xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>leadqualitycode</b:key> 
      <b:value i:type="a:OptionSetValue"> 
       <a:Value>2</a:Value> 
      </b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>statuscode</b:key> 
      <b:value i:type="a:OptionSetValue"> 
       <a:Value>1</a:Value> 
      </b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>ownerid</b:key> 
      <b:value i:type="a:EntityReference"> 
       <a:Id>{6710C3A0-6EE9-E211-B17C-984BE16D3DAA}</a:Id> 
       <a:LogicalName>systemuser</a:LogicalName> 
       <a:Name i:nil="true" /> 
      </b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>decisionmaker</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:boolean">0</b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>salesstage</b:key> 
      <b:value i:type="a:OptionSetValue"> 
       <a:Value>0</a:Value> 
      </b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>subject</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:string">subject</b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>lastname</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:string">vladislav</b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>transactioncurrencyid</b:key> 
      <b:value i:type="a:EntityReference"> 
       <a:Id>{5B1C0B98-6CE9-E211-8B44-984BE17C9A7B}</a:Id> 
       <a:LogicalName>transactioncurrency</a:LogicalName> 
       <a:Name i:nil="true" /> 
      </b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>preferredcontactmethodcode</b:key> 
      <b:value i:type="a:OptionSetValue"> 
       <a:Value>1</a:Value> 
      </b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>donotemail</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:boolean">0</b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>donotbulkemail</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:boolean">0</b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>donotphone</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:boolean">0</b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>donotpostalmail</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:boolean">0</b:value> 
     </a:KeyValuePairOfstringanyType> 
     <a:KeyValuePairOfstringanyType> 
      <b:key>donotsendmm</b:key> 
      <b:value xmlns:c="http://www.w3.org/2001/XMLSchema" i:type="c:boolean">0</b:value> 
     </a:KeyValuePairOfstringanyType> 
     </a:Attributes> 
     <a:EntityState i:nil="true" /> 
     <a:FormattedValues xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /> 
     <a:Id>00000000-0000-0000-0000-000000000000</a:Id> 
     <a:LogicalName>lead</a:LogicalName> 
     <a:RelatedEntities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /> 
    </entity> 
</Create> 
+0

此答案似乎無效。但是,您是如何提出這種解決方案的? – user1652382

+0

@ user1652382此代碼有效。我在測試之前對它進行了測試。 有幾個例子,我發現有用的。當你說它返回「false」時,你如何得到這個結果?您應該能夠閱讀應該告訴您它是否成功的SOAP響應。 我已經開始在這裏記錄一些SOAP-CRM的東西 http://crmtroubleshoot.blogspot.com.au/2013/07/dynamics-crm-2011-php-and-soap-using.html 你用什麼方法調用你的SOAP? 什麼認證類型? – Campey

+0

@ user1652382您現在是否已成功處理上述請求? – Campey