2014-12-06 85 views
0

我在使用MS Dynamics CRM 2013 SOAP API创建案例(又名事件)实体时遇到问题。我认为我已经把它缩小到一个与定制类型有关的参考的麻烦,但是尽管进行了相当多的研究,但仍然无法解决。如何使用SOAP API在Microsoft Dynamics CRM 2013中创建案例实体?

下面是我使用的创建XML:

<create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <entity> 
     <b:attributes> 
      <b:keyvaluepairofstringanytype> 
       <c:key>customerid</c:key> 
       <c:value i:type="b:EntityReference"> 
        <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
        <b:logicalname>account</b:logicalname> 
        <b:name>Testing Account</b:name> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_email</c:key> 
       <c:value i:type="d:string">[email protected]</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_phone</c:key> 
       <c:value i:type="d:string">111-222-3333</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>description</c:key> 
       <c:value i:type="d:string">This is a test. Please do not respond to this case.</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>statuscode</c:key> 
       <c:value i:type="b:OptionSetValue"> 
        <b:value>1</b:value> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>prioritycode</c:key> 
       <c:value i:type="b:OptionSetValue"> 
        <b:value>2</b:value> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_date</c:key> 
       <c:value i:type="d:dateTime">2014-12-06T09:56:00</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_cstadmin</c:key> 
       <c:value i:type="b:OptionSetValue"> 
        <b:value>100000015</b:value> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>title</c:key> 
       <c:value i:type="d:string">Test Case by XYZ</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>subjectid</c:key> 
       <c:value i:type="b:EntityReference"> 
        <b:id>41b106d1-074a-e411-b697-9cb654957388</b:id> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
     </b:attributes> 
     <b:logicalname>incident</b:logicalname> 
    </entity> 
</create> 

当我提出这一点,我得到一个HTTP-500回来了,错误,

您应该指定一个父联系人或帐户

我认为这意味着这块xml ...

  <b:keyvaluepairofstringanytype> 
       <c:key>customerid</c:key> 
       <c:value i:type="b:EntityReference"> 
        <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
        <b:logicalname>account</b:logicalname> 
        <b:name>Testing Account</b:name> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 

...没有充分参考案例的父帐户。所以我认为我的语法是不正确的。我选择这种语法的原因是,它反映了我检索案例时返回的相同表单。

我也尝试了稍微不同的语法通过准备“客户ID”和“customeridtype”属性作为单独的键值对,如:

 <b:keyvaluepairofstringanytype> 
      <c:key>customeridtype</c:key> 
      <c:value i:type="d:string">account</c:value> 
     </b:keyvaluepairofstringanytype> 
     <b:keyvaluepairofstringanytype> 
      <c:key>customerid</c:key> 
      <c:value i:type="b:EntityReference"> 
       <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
      </c:value> 
     </b:keyvaluepairofstringanytype> 

...但仍,没有骰子。

任何人有任何想法?

+0

你是怎么创建这个XML的? – 2014-12-07 11:23:48

+0

我正在使用云到云平台服务 - itDuzzit - 将它放在一起。 – 2014-12-07 16:02:23

回答

0

AFAIK customeridcustomeridtype都应该在那里(因为特殊的“客户”字段结构),所以我想尝试的两次尝试混合:

<b:keyvaluepairofstringanytype> 
    <c:key>customerid</c:key> 
    <c:value i:type="b:EntityReference"> 
     <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
     <b:logicalname>account</b:logicalname> 
     <b:name>Testing Account</b:name> 
    </c:value> 
</b:keyvaluepairofstringanytype> 
<b:keyvaluepairofstringanytype> 
    <c:key>customeridtype</c:key> 
    <c:value i:type="d:string">1</c:value> 
</b:keyvaluepairofstringanytype> 

注意customeridtype包含类型代码为在我尝试

<c:value i:type="d:string">1</c:value> 

这就是说,作为一个侧面说明,如果你可以把它使你的数据出来作为JSON,你可以将其发布到了OData服务(导致更少的痛苦经历)号。

+0

一个很好的想法,但是我仍然遇到同样的错误“当我尝试这种技术时”您应该指定一个父级联系人或帐户。“并且我同意OData服务可能更透明,但它不适合我在这一点上,不幸的是。 – 2014-12-10 14:03:31

0

Customer字段是一个非常特殊的字段,因此,而不是将一个EntityReference传递到该帐户,而是尝试传递一个“b:Customer”对象,看看是否有用?另外,不要浪费时间手动生成请求,对于SOAP或REST端点使用SDK工具(如Sdk.Soap.js)(要简单得多)。

相关问题