SOAP XML Property Order is Important

When you construct a SOAP message yourself, when using Perl, for instance, the order of the properties within the SOAP XML element is critical. For example, the UserCredentials type has two properties, Username and Password. The SOAP XML for an instance of this type would look like this:

<UserCredentials xmlns="https://adcenter.microsoft.com/api/advertiser/v5">
<Password>My_Password</Password>
<Username>My_Username</Username>
</UserCredentials>

Notice that the Password property is first, followed by Username. The order of the properties in the XML is important because the adCenter deserializer will not interpret the contents of the element correctly if the properties are not in the correct order.

You can determine the correct order of the properties from the WSDL. For example, the following is the definition of the UserCredentials type in https://adcenterapi.microsoft.com/Api/Advertiser/V5/CampaignManagement/CampaignManagementService.svc?xsd=xsd0,

<xs:complexType name="UserCredentials">
<xs:sequence>
<xs:element minOccurs="0" name="Password" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="Username" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>

All types must be constructed in the sequence that they are specified.

To give another example, the KeywordBid type is defined as:

<xs:complexType name="KeywordBid">
<xs:sequence>
<xs:element minOccurs="0"
name="BroadMatchBid"
nillable="true"
type="xs:double" />
<xs:element minOccurs="0"
name="ExactMatchBid"
nillable="true"
type="xs:double" />
<xs:element name="Keyword"
nillable="true"
type="xs:string" />
<xs:element minOccurs="0"
name="PhraseMatchBid"
nillable="true"
type="xs:double" />
</xs:sequence>
</xs:complexType>

This means that the properties for this type, if included, must be in the following order:

BroadMatchBid
ExactMatchBid
Keyword
PhraseMatchBid

Thank You,

Strohm Armstrong
Programming Writer - adCenter SDK