sdk-dotnet
sdk-dotnet copied to clipboard
Serialization order anomaly for customerAddressType
We're adding billTo in the transactionRequestType:
var billingAddress = new customerAddressType
{
firstName = model.FirstName,
lastName = model.LastName,
address = $"{model.AddressLine1} {model.AddressLine2}",
city = model.City,
state = model.State,
zip = model.ZipCode
};
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(),
amount = (decimal)model.PaymentAmount,
payment = paymentType,
order = new orderType
{
description = model.PaymentOrigin.ToString(),
invoiceNumber = model.InvoiceKey
},
billTo = billingAddress,
lineItems = lineItems
};
However, we are consistently receiving errors when we execute the request:
"E00003:The element 'billTo' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'state' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'country, phoneNumber, faxNumber, email' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."
I deserialize the class using this approach:
var serializer =
new XmlSerializer(typeof(customerAddressType));
using (FileStream file = new FileStream("C:/temp/billing.xml", FileMode.Create, System.IO.FileAccess.Write))
{
serializer.Serialize(file, billingAddress);
}
which outputs the following structure:
<?xml version="1.0"?>
<customerAddressType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<address xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">ADDRESS</address>
<city xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">CITY</city>
<zip xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">ZIP</zip>
<state xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">STATE</state>
<firstName xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">FIRSTNAME</firstName>
<lastName xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">LASTNAME</lastName>
</customerAddressType>
It seems like the xml serialization is outputting the fields in the incorrect order....otherwise please advise on field order or other issues we may be overlooking.
Hi, Apologies for the delay.
We will relay this issue to a relevant team.
And?