I am using PHP to connect to a Dynamics 2011 IFD and successfully authenticating and retrieving contacts to my web application.
I am however struggling to update a contact.
My SOAP request (below) is returning 'Bad Request' and unfortunately I do not have sufficient admin access to the server to enable more useful error reporting. Can anyone spot anything obvious in this XML which may be the issue?
$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>'
The 'getSoapHeaderOnPremise' function is returning working auth headers for the retrieve/retrieveMultiple requests. The only difference here being the Update method being specified:
<a:Action s:mustUnderstand="1">http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Update</a:Action>