Microsoft Dynamics CRM is driving me nuts these days (and sadly I'm completely new to this stuff). I'm trying to add via PHP/SOAP a new record to Microsoft Dynamics CRM 2013 Account entity but I keep getting no answers. According to Campey's blog an ADD xml request Body should contain "create" tag like this
<create xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
<entity xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
<a:attributes xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<!-- ATTRIBUTE XML GOES HERE!! -->
</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><!-- ENTITY NAME GOES HERE!! --></a:logicalname>
<a:relatedentities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
</a:relatedentities></a:formattedvalues></a:entitystate></entity>
</create>
I already have a working script downloading items list using "request" tag so I am sure that "Header" part is fully working and I can concentrate on "s:Body". I put Campey's example snippet inside "Execute->request" tag, as follows. BUT this causes me errors. Seems is connected to request tag xmlns attribute but not sure about that. Thanx in advance for your precious help!
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:request.
The InnerException message was 'Error in line 2 position 38.
Element 'http://schemas.microsoft.com/xrm/2011/Contracts/Services:request' contains data from a type that maps to the name 'http://www.w3.org/2005/08/addressing:CreateRequest'.
The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'CreateRequest' and namespace 'http://www.w3.org/2005/08/addressing'.'. Please see InnerException for more detail
XML structure
<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<request i:type="a:CreateRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
<create xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
<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>name</b:key>
<b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">aaa-test</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>account</a:logicalname>
<a:relatedentities xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
</a:relatedentities></a:formattedvalues></a:entitystate></entity>
</create>
</request>
</Execute>
[SOLUTION] UPDATE AFTER HOURS OF WTFing I still don't know why but I had to remove "create" tag and use just execute->request. Once I placed a "request" tag with CreateRequest type it worked. That's the code in case someone else needs it. Not sure if there had been a change of the XML structure from CRM 2011 to CRM 2013 or it was just badly documented. By the way, thanx a lot for your help!
<Execute xmlns='http://schemas.microsoft.com/xrm/2011/Contracts/Services' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<request i:type='a:CreateRequest' 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>Target</b:key>
<b:value i:type='a:Entity'>
<a:Attributes>
<a:KeyValuePairOfstringanyType>
<b:key>name</b:key>
<b:value i:type='c:string' xmlns:c='http://www.w3.org/2001/XMLSchema'>test1234</b:value>
</a:KeyValuePairOfstringanyType>
</a:Attributes>
<a:EntityState i:nil='true' />
<a:FormattedValues />
<a:Id>00000000-0000-0000-0000-000000000000</a:Id>
<a:LogicalName>account</a:LogicalName>
<a:RelatedEntities />
</b:value>
</a:KeyValuePairOfstringanyType>
</a:Parameters>
<a:RequestId i:nil='true' />
<a:RequestName>Create</a:RequestName>
</request>
</Execute>