I am facing a problem when triying to use the filter of the method 'retrieve' for the SOAP API of Exact Target. I dont know how to set an attribute to a node of the xml generated when using WebServiceCallout.
I need a generated xml like this (see xsi:type in Filter):
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<n1:fueloauth xmlns="http://exacttarget.com/wsdl/partnerAPI" xmlns:n1="http://exacttarget.com">
<fueloauth>MyAuthToken</fueloauth>
</n1:fueloauth>
</env:Header>
<env:Body>
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<RetrieveRequest>
<ObjectType>DataExtensionObject[XXXXXXXXXXXXXX]</ObjectType>
<Properties>Email Address</Properties>
<Properties>Date Added</Properties>
<Filter xsi:type="SimpleFilterPart">
<Property>Email Address</Property>
<SimpleOperator>equals</SimpleOperator>
<Value>testMail@gmail.com</Value>
</Filter>
</RetrieveRequest>
</RetrieveRequestMsg>
</env:Body>
</env:Envelope>
But I'am getting one without the attribute in Filter:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<n1:fueloauth xmlns="http://exacttarget.com/wsdl/partnerAPI" xmlns:n1="http://exacttarget.com">
<fueloauth>MyAuthToken</fueloauth>
</n1:fueloauth>
</env:Header>
<env:Body>
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<RetrieveRequest>
<ObjectType>DataExtensionObject[XXXXXXXXXXXXXXXXXXXXXX]</ObjectType>
<Properties>Email Address</Properties>
<Properties>Date Added</Properties>
<Filter>
<Property>Email Address</Property>
<SimpleOperator>equals</SimpleOperator>
<Value>testMail@gmail.com</Value>
</Filter>
</RetrieveRequest>
</RetrieveRequestMsg>
</env:Body>
</env:Envelope>
The code I'm using to fill the request (consider ET_WSDL the autogenerated class from the exactTarget WSDL from salesforce):
ET_WSDL.Soap soapRequest = new ET_WSDL.Soap();
ET_WSDL.fueloauth header = new ET_WSDL.fueloauth();
header.fueloauth = 'MyAuthtoken';
soapRequest.HeaderFOAuth = header;
ET_WSDL.RetrieveRequest retrieveRequest = new ET_WSDL.RetrieveRequest();
ET_WSDL.SimpleFilterPart filterPart = new ET_WSDL.SimpleFilterPart();
retrieveRequest.ObjectType = 'DataExtensionObject[XXXXXXXXXX]';
retrieveRequest.Properties = new String[]{'Email Address', 'Date Added'};
filterPart.Property = 'Email Address';
filterPart.SimpleOperator = 'equals';
filterPart.Value = new String[]{'emailtest@test.com'};
retrieveRequest.Filter = filterPart;
ET_WSDL.RetrieveResponseMsg_element response = soapRequest.Retrieve_x(retrieveRequest);
system.debug('SOAP: '+response);
I've changed the code of the class RetrieveRequest FilterPart--> SimpleFilterPart:
public class RetrieveRequest {
public ET_WSDL.ClientID[] ClientIDs;
public String ObjectType;
public String[] Properties;
//OLD public ET_WSDL.FilterPart Filter;
public ET_WSDL.SimpleFilterPart Filter;//NEW
[...]
But it doesn't add the attribute.
Anyone else facing the same issue?
Thanks in advance