Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization order anomaly for customerAddressType #272

Open
kfallstrom opened this issue Oct 23, 2019 · 2 comments
Open

Serialization order anomaly for customerAddressType #272

kfallstrom opened this issue Oct 23, 2019 · 2 comments

Comments

@kfallstrom
Copy link

kfallstrom commented Oct 23, 2019

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.

@gnongsie
Copy link
Contributor

Hi,
Apologies for the delay.

We will relay this issue to a relevant team.

@boylec
Copy link

boylec commented Feb 20, 2022

And?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants