Error in deserializing body of reply message for operation 'syncMObjects'

Anonymous
Not applicable

Error in deserializing body of reply message for operation 'syncMObjects'

When Creating Opportunity with following association, service fails the deserilization with following  error

Error in deserializing body of reply message for operation 'syncMObjects'

Code:

var Opportunity. = new MObject();

Opportunity.type = "Opportunity";
Opportunity.associationList = new[] { new MObjAssociation() };               
Opportunity.associationList[0].mObjType = "Company";
Opportunity.associationList[0].externalKey = new Attrib();
Opportunity.associationList[0].externalKey.name = "CrmAccount_Id";
Opportunity.associationList[0].externalKey.value = "4d463e3b-0176-0eb8-c80b-50ae65e11bfd";

and sync the opportunity to Marketo...

Actual message return from service ( on fiddler) is

Association type 'Company' with 'CrmAccount_Id' value '4d463e3b-0176-0eb8-c80b-50ae65e11bfd' not found

if i create 100 opportunity at a time, entire batch will fail even if only one opportunity has wrong value.

Tags (1)
1 REPLY 1
Anonymous
Not applicable

Re: Error in deserializing body of reply message for operation 'syncMObjects'

I found the reason why I was getting deserializing  error instead of status of each batch item.

There is problem on WSDL


<xs:complexType name="MObjStatus">
<xs:sequence>
<xs:element name="id" type="xs:int" minOccurs="1" maxOccurs="1" nillable="false"/>
<xs:element name="externalKey" type="tns:Attrib" minOccurs="0" maxOccurs="1" nillable="false"/>
<xs:element name="status" type="tns:MObjStatusEnum" minOccurs="1" maxOccurs="1" nillable="false"/>
<xs:element name="error" type="xs:string" minOccurs="0" maxOccurs="1" nillable="false"/>
</xs:sequence>
</xs:complexType>

When add/update Mobject fails, the service API does not return id, hence result can not be deserialized.  To solve the problem, either service must return some integer value on failure . e.g. 0 or  -1.

Or WSDL must be modifed to accomodate empty value.

That can be done two ways,  1) Make id nullable, or 2) Make id string

I solved my problem by changing the datatype to string

<xs:complexType name="MObjStatus">

<xs:sequence>
<xs:element name="id" type="xs:string" minOccurs="1" maxOccurs="1" nillable="false"/>
<xs:element name="externalKey" type="tns:Attrib" minOccurs="0" maxOccurs="1" nillable="false"/>
<xs:element name="status" type="tns:MObjStatusEnum" minOccurs="1" maxOccurs="1" nillable="false"/>
<xs:element name="error" type="xs:string" minOccurs="0" maxOccurs="1" nillable="false"/>
</xs:sequence>
</xs:complexType>