0

I am generating an XML file that I am sending to another system. The XML file generates correctly however the secondary system requires specific headers to deserialize correctly.

I am struggling with the XML tags and how to structure my classes that insert the data.

PostShipmentNotesBD -> ShipmentNoteBD -> Shipmentheader -> ShipmentDetailsBD -> MerchandiseLineBD
[XmlType("PostShipmentNotes")] -> [XmlType("ShipmentNote")] -> [XmlType("ShipmentHeader")] -> [XmlType("ShipmentDetails")] -> [XmlType("MerchandiseLine")]

For whatever reason the PostShipmentNotes and MerchandiseLines use the XMLType as the header but the rest do not? I have played around with roots, elements and more but I am a bit out of my area of knowledge and just looking for the right direction.

<?xml version="1.0" encoding="utf-8"?>
<PostShipmentNotes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ShipmentNoteBD>
    <ShipmentHeader>
      <CustomerName>Some Company</CustomerName>
      <ShipmentStatusPrinted>Y</ShipmentStatusPrinted>
      <ShipCode>1010</ShipCode>
      <PlannedShipmentDate>2021-11-10</PlannedShipmentDate>
      <SalesOrder>666777</SalesOrder>
      <ShipAddress1>Big Long Street Name</ShipAddress1>
      <ShipAddress2> </ShipAddress2>
    </ShipmentHeader>
    <ShipmentDetailsBD>
      <MerchandiseLine>
        <SalesOrderLine>1</SalesOrderLine>
        <ShipmentQty>21</ShipmentQty>
        <OverOrUnderShipment>N</OverOrUnderShipment>
      </MerchandiseLine>
    </ShipmentDetailsBD>
  </ShipmentNoteBD>
</PostShipmentNotes>
3
  • 2
    The following may be helpful: stackoverflow.com/questions/68605811/… and stackoverflow.com/questions/68875589/… . Alternatively, you can also add a new class. Then copy your XML (ex: ctrl-C), In VS menu, click: Edit => Paste Special => Paste XML As Classes. Commented Nov 7, 2021 at 23:31
  • Cheers the second link helped me figure it out. My nested classes could be defined as XmlElement within the parent class rather than trying to define the XmlType Commented Nov 8, 2021 at 1:01
  • Header are not XML, they are HTML headers that is used as part of the HTML Request/Response. If you are using SML Serialization the headers may be attributes that you are adding to the c# classes. Commented Nov 8, 2021 at 12:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.