1

For WebAPI XML request can the XML namespace can be ignored while model binding.

I want all the below requests to be bind correctly to my OrderHeader object:

<OrderHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <OrderDate>2015-07-20T15:00:00</OrderDate>
  <CustomerAccountNumber>TEST1</CustomerAccountNumber>
  <CustomerPONumber>TEST2</CustomerPONumber>
  <CustomerReferenceNumber />
</OrderHeader>

<OrderHeader>
  <OrderDate>2015-07-20T15:00:00</OrderDate>
  <CustomerAccountNumber>TEST1</CustomerAccountNumber>
  <CustomerPONumber>TEST2</CustomerPONumber>
  <CustomerReferenceNumber />
</OrderHeader>

<OrderHeader xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/TEST.Models.API">
  <OrderDate>2015-07-20T15:00:00</OrderDate>
  <CustomerAccountNumber>TEST1</CustomerAccountNumber>
  <CustomerPONumber>TEST2</CustomerPONumber>
  <CustomerReferenceNumber />
</OrderHeader>

1 Answer 1

0

config.Formatter.XmlFormatter will get you where you want to go. There u can ignore namespace using properties on the formatter.

Sign up to request clarification or add additional context in comments.

1 Comment

Could you give me the specific properties you are talking about. I already some of them. I couldn't find related to the read settings.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.