我正在使用PHP连接到Dynamics 2011 IFD,并成功地验证和检索我的web应用程序的联系人。
然而,我正在努力更新联系人。
我的SOAP请求(如下)返回'Bad Request‘,不幸的是,我没有足够的服务器管理员访问权限来启用更有用的错误报告。有没有人能发现这个XML中有什么明显的问题呢?
$request = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
'.$this->crmAuth->GetSoapHeaderOnPremise("Update").'
<s:Body>
<Update 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>contactid</b:key>
<b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">'.$contactid.'</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>firstname</b:key>
<b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">'.$firstname.'</b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType>
<b:key>lastname</b:key>
<b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">'.$lastname.'</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>'.$contactid.'</a:Id>
<a:LogicalName>contact</a:LogicalName>
<a:RelatedEntities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
</entity>
</Update>
</s:Body>
</s:Envelope>''getSoapHeaderOnPremise‘函数正在为retrieve/retrieveMultiple请求返回可用的auth标头。这里唯一的区别是指定了Update方法:
<a:Action s:mustUnderstand="1">http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Update</a:Action>发布于 2016-06-03 08:12:36
这是一个大胆的猜测,因为我自己还没有执行过这样的更新。
去掉这个比特,
<a:KeyValuePairOfstringanyType>
<b:key>contactid</b:key>
<b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">'.$contactid.'</b:value>
</a:KeyValuePairOfstringanyType>这表明您正在尝试设置记录id字段,这不是您通常要做的事情。
您有一个似乎将您的更新与单个记录相关联的位,所以我怀疑上面的内容不是必需的。
<a:Id>'.$contactid.'</a:Id>发布于 2016-06-03 16:02:43
我从来没有用过它,但是看起来有一个project on Git可以解决这个问题。
https://stackoverflow.com/questions/37589407
复制相似问题