Xml反序列化工作(200 OK),但不能带来内容

时间:2015-11-10 22:06:32

标签: c# xml asp.net-mvc serialization

我有一个以下的视图端模型方案以及控制器代码,它基本上对XML文档进行GET请求,并将其反序列化到模型中。我得到200 OK响应并且反序列化方法有效,但转换对象内的内容不存在。

控制器代码

      string OneURL = "https://seller.marketplace.sears.com/SellerPortal/s/schema/samples/rest/oms/export/v11/purchase-order.xml";
      HttpClient client = new HttpClient();
      HttpResponseMessage ResponseMessage = new HttpResponseMessage();
      try {
        ResponseMessage = client.GetAsync(OneURL).Result;


        string ResultString = ResponseMessage.Content.ReadAsStringAsync().Result;
        ResultString = ResultString.Replace("<sup>™</sup>", "");
        ResultString = ResultString.Replace("<sup>®</sup>", "");

        TextReader Input = new StringReader(ResultString);
        XmlSerializer DebugSerializer = new XmlSerializer(typeof(SearsPurchaseOrderResponseModel));
        SearsPurchaseOrderResponseModel XmlResponse = new SearsPurchaseOrderResponseModel();
        try {
          XmlResponse = (SearsPurchaseOrderResponseModel)DebugSerializer.Deserialize(Input);}catch(Exception e){}

模特

 // order retrieval model
  [Serializable]
  [XmlRoot(ElementName = "po-response", Namespace = "http://seller.marketplace.sears.com/oms/v11")]
  public class SearsPurchaseOrderResponseModel {
    [XmlElement("deprecated")]
    public DateTime Deprecated { get; set; }

    [Required]
    [XmlArrayItem("purchase-order")]
    public List<SearsPurchaseOrderModel> PurchaseOrder { get; set; }
  }



  [Serializable]
  //[XmlType("purchase-order")]
  public class SearsPurchaseOrderModel {

    [XmlElement("customer-order-confirmation-number")]
    public int CustomOrderConfirmationNumber { get; set; }
    [XmlElement("customer-email")]
    public string CustomerEmail { get; set; }
    [Required]
    [XmlElement("po-number")]
    public string PONumber { get; set; }
    [Required]
    [XmlElement("po-date")]
    public DateTime PODate { get; set; }
    [Required]
    [XmlElement("po-time")]
    public TimeSpan POTime { get; set; }
    [Required]
    [XmlElement("po-number-with-date")]
    public string PONumberWithDate { get; set; }
    [XmlElement("unit")]
    public string Unit { get; set; }
    [XmlElement("site")]
    public string Site { get; set; }
    [XmlElement("channel")]
    public string Channel { get; set; }
    [XmlElement("location-id")]
    public string LocationID { get; set; }
    [XmlElement("lmp-details")]
    public SearsOrderLMPDetailModel LMPDetail { get; set; }
    [Required]
    [XmlElement("expected-ship-date")]
    public DateTime ExpectedShipDate { get; set; }
    [Required]
    [XmlElement("shipping-detail")]
    public SearsOrderShippingDetailModel ShippingDetail { get; set; }

    [XmlElement("ship-to-store-detail")]
    public SearsOrderShipToStoreDetailModel ShipToStoreDetail { get; set; }

    [Required]
    [MaxLength(100)]
    [XmlElement("customer-name")]
    public string CustomerName { get; set; }

    [Required]
    [XmlArrayItem("po-line")]
    public List<SearsOrderPOLineModel> POLine { get; set; }


    [Required]
    [XmlElement("order-total-sell-price")]
    public decimal OrderStoreSellPrice { get; set; }

    [Required]
    [XmlElement("total-commission")]
    public decimal TotalCommission { get; set; }

    [Required]
    [XmlElement("total-shipping-handling")]
    public decimal TotalShippingHandling { get; set; }

    [Required]
    [XmlElement("balance-due")]
    public decimal BalanceDue { get; set; }

    [Required]
    [XmlElement("sales-tax")]
    public decimal SalesTax { get; set; }

    [Required]
    [XmlElement("po-status")]
    public string POStatus { get; set; }

    [XmlElement("po-shipment-info")]
    public SearsOrderShipmentInfoModel POShipmentInfo { get; set; }

  }

  [Serializable]
  public class SearsOrderShippingDetailModel {
    [Required]
    [MaxLength(100)]
    [XmlElement("ship-to-name")]
    public string ShipToName { get; set; }
    [Required]
    [XmlElement("address")]
    public string Address { get; set; }
    [Required]
    [XmlElement("city")]
    public string City { get; set; }
    [Required]
    [XmlElement("state")]
    public string State { get; set; }
    [Required]
    [XmlElement("zipcode")]
    public string Zipcode { get; set; }
    [Required]
    [XmlElement("phone")]
    public string Phone { get; set; }
    [Required]
    [XmlElement("shipping-method")]
    public string ShippingMethod { get; set; }
    [XmlElement("carrier")]
    public string Carrier { get; set; }
  }



  [Serializable]
  public class SearsOrderShipmentInfoModel {
    [Required]
    [XmlArrayItem("shipment")]
    public List<SearsOrderShipmentDetailModel> Shipment { get; set; }
  }

  [Serializable]
  public class SearsOrderShipmentDetailModel {
    [Required]
    [XmlElement("ship-method")]
    public string ShipMethod { get; set; }
    [Required]
    [MaxLength(45)]
    [XmlElement("shipment-tracking-number")]
    public string ShipmentTrackingNumber { get; set; }
  }



  [Serializable]
  public class SearsOrderLMPDetailModel {

    [Required]
    [XmlElement("order-type")]
    public string OrderType { get; set; }
    [Required]
    [XmlElement("pickup-ind")]
    public string PickupIND { get; set; }
    [Required]
    [XmlElement("pickup-location")]
    public SearsOrderPickupLocationModel PickupLocation { get; set; }
    [XmlElement("delivery-instructions")]
    public string DeliveryInstructions { get; set; }
    [XmlElement("dropoff-ind")]
    public string DropoffIND { get; set; }
    [XmlElement("delivery-date")]
    public DateTime DeliveryDate { get; set; }
    [XmlElement("expected-pickup-date")]
    public DateTime ExpectedPickupDate { get; set; }
    [Required]
    [XmlElement("ucc-barcode")]
    public string UCCBarcode { get; set; }


  }

  [Serializable]
  public class SearsOrderPickupLocationModel {
    [Required]
    [XmlElement("name")]
    public string Name { get; set; }
    [Required]
    [XmlElement("address")]
    public string Address { get; set; }
    [Required]
    [XmlElement("city")]
    public string City { get; set; }
    [Required]
    [XmlElement("state")]
    public string State { get; set; }
    [Required]
    [XmlElement("zipcode")]
    public string Zipcode { get; set; }
    [Required]
    [XmlElement("phone")]
    public string Phone { get; set; }

  }

  [Serializable]
  public class SearsOrderPOLineModel {
    [Required]
    [XmlElement("po-line-header")]
    public SearsOrderPOLineHeaderModel POLineHeader { get; set; }
    [XmlArrayItem("po-line-detail")]
    public List<SearsOrderPOLineDetailModel> POLineDetail { get; set; }
  }

  [Serializable]
  public class SearsOrderPOLineHeaderModel {
    [Required]
    [XmlElement("line-number")]
    public int LineNumber { get; set; }
    [Required]
    [MaxLength(50)]
    [XmlElement("item-id")]
    public string ItemID { get; set; }
    [Required]
    [XmlElement("item-name")]
    public string ItemName { get; set; }
    [XmlElement("handling-instructions")]
    public string HandlingInstructions { get; set; }
    [XmlElement("handling-ind")]
    public string HandlingIND { get; set; }
    [XmlElement("unit-cost")]
    public decimal UnitCost { get; set; }
    [XmlElement("selling-price-each")]
    public decimal SellingPriceEach { get; set; }
    [Required]
    [XmlElement("commission")]
    public decimal Commission { get; set; }
    [Required]
    [Range(0, Int32.MaxValue)]
    [XmlElement("order-quantity")]
    public int OrderQuantity { get; set; }
    [Required]
    [XmlElement("shipping-and-handling")]
    public decimal ShippingAndHandling { get; set; }
    [XmlElement("gift-message-details")]
    public string GiftMessageDetails { get; set; }
    [XmlElement("customer-cancellation-warning")]
    public string CustomerCancellationWarning { get; set; }

  }

  [Serializable]
  public class SearsOrderPOLineDetailModel {
    [Required]
    [XmlElement("po-line-status")]
    public string POLineStatus { get; set; }
    [Required]
    [XmlElement("quantity")]
    public int Quantity { get; set; }
    [XmlElement("internal-memo")]
    public string InternalMemo { get; set; }
    [XmlElement("external-memo")]
    public string ExternalMemo { get; set; }
  }

  [Serializable]
  public class SearsOrderShipToStoreDetailModel {
    [Required]
    [XmlElement("address")]
    public string Address { get; set; }
    [Required]
    [XmlElement("city")]
    public string City { get; set; }
    [Required]
    [XmlElement("state")]
    public string State { get; set; }
    [Required]
    [XmlElement("zipcode")]
    public string Zipcode { get; set; }
    [XmlElement("phone")]
    public string Phone { get; set; }
    [XmlElement("store-delivery-date")]
    public DateTime StoreDeliveryDate { get; set; }
    [Required]
    [XmlElement("ucc-barcode")]
    public string UCCBarcode { get; set; }

  }

XML文件

<?xml version="1.0" encoding="UTF-8"?>
<po-response xsi:schemaLocation="rest/oms/export/v11/purchase-order.xsd" xmlns="http://seller.marketplace.sears.com/oms/v11" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <purchase-order>
    <!--This is a shipping order -->
    <customer-order-confirmation-number>650637711</customer-order-confirmation-number>
    <!--confirmation number customer sees in his order confirmation email and 
            order center -->
    <customer-email>bx2vzj_16q8lboz_67@seller.sears.com</customer-email>
    <po-number>408306531</po-number>
    <po-date>2014-10-02</po-date>
    <po-time>05:22:59</po-time>
    <po-number-with-date>20141002408306531</po-number-with-date>
    <unit>9300</unit>
    <site>SEARS</site>
    <channel>DSS</channel>
    <location-id>8446</location-id>
    <expected-ship-date>2014-09-09</expected-ship-date>
    <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>3400 ParkWay RD</address>
      <city>CONCORD</city>
      <state>GA</state>
      <zipcode>30206</zipcode>
      <phone>7703311985</phone>
      <shipping-method>Standard</shipping-method>
      <carrier>DEMAR</carrier>
    </shipping-detail>
    <customer-name>John Doe</customer-name>
    <po-line>
      <!--There could be multiple line items within an order and your items 
                    may or may not start with line number 1 -->
      <po-line-header>
        <line-number>1</line-number>
        <!--Item id can have 50 characters -->
        <item-id>12321</item-id>
        <item-name>DSS Item</item-name>
        <unit-cost>14.99</unit-cost>
        <!-- Unit Cost included only for DSS orders -->
        <selling-price-each>17.63</selling-price-each>
        <unit-sales-tax>1.86</unit-sales-tax>
        <commission>2.64</commission>
        <order-quantity>1</order-quantity>
        <shipping-and-handling>8.95</shipping-and-handling>
        <unit-shipping-tax>0.00</unit-shipping-tax>
        <fees>
          <unit-fee type="REGULATORY">1.12</unit-fee>
        </fees>
        <customer-cancellation-warning><![CDATA[This line item has a cancellation request from customer. Before fulfilling the line, please use the following service for more details - https://seller.marketplace.sears.com/SellerPortal/api/oms/cancellationrequest/v1?email={emailaddress}&password={password}&status={status}&fromdate={fromdate}&todate={todate}]]></customer-cancellation-warning>
      </po-line-header>
      <po-line-detail>
        <po-line-status>NEW</po-line-status>
        <quantity>1</quantity>
      </po-line-detail>
    </po-line>
    <order-total-sell-price>17.63</order-total-sell-price>
    <total-commission>2.64</total-commission>
    <total-shipping-handling>8.95</total-shipping-handling>
    <balance-due>23.94</balance-due>
    <!--balance due=order total seller price -total comission +total shipping 
            handling -->
    <sales-tax>1.86</sales-tax>
    <!--sales tax is collected and submitted by Sears -->
    <po-status>New</po-status>
  </purchase-order>
  <purchase-order>
    <customer-order-confirmation-number>650637712</customer-order-confirmation-number>
    <customer-email>bx2vzj_16q8lboz_67@seller.sears.com</customer-email>
    <po-number>408306532</po-number>
    <po-date>2014-10-02</po-date>
    <po-time>05:22:59</po-time>
    <po-number-with-date>20141002408306532</po-number-with-date>
    <unit>9301</unit>
    <site>SEARS</site>
    <channel>FBM</channel>
    <location-id>8446</location-id>
    <expected-ship-date>2014-09-09</expected-ship-date>
    <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>3400 ParkWay RD</address>
      <city>CONCORD</city>
      <state>GA</state>
      <zipcode>30206</zipcode>
      <phone>7703311985</phone>
      <shipping-method>Premium</shipping-method>
    </shipping-detail>
    <customer-name>John Doe</customer-name>
    <po-line>
      <po-line-header>
        <line-number>1</line-number>
        <item-id>12321</item-id>
        <item-name>Item Name</item-name>
        <selling-price-each>64.95</selling-price-each>
        <unit-sales-tax>6.10</unit-sales-tax>
        <commission>9.74</commission>
        <order-quantity>1</order-quantity>
        <shipping-and-handling>8.95</shipping-and-handling>
        <unit-shipping-tax>0.00</unit-shipping-tax>
      </po-line-header>
      <po-line-detail>
        <po-line-status>SHIPPED</po-line-status>
        <quantity>1</quantity>
      </po-line-detail>
    </po-line>
    <order-total-sell-price>64.95</order-total-sell-price>
    <total-commission>9.74</total-commission>
    <total-shipping-handling>8.95</total-shipping-handling>
    <balance-due>64.16</balance-due>
    <sales-tax>6.10</sales-tax>
    <po-status>Closed</po-status>
    <po-shipment-info>
      <shipment>
        <ship-method>DEMAR</ship-method>
        <shipment-tracking-number>DEMARPREMIUM1234567890</shipment-tracking-number>
      </shipment>
    </po-shipment-info>
    <tax-reference>
      <delivery-tax-code>1</delivery-tax-code>
      <tax-rate>14260</tax-rate>
      <avp-taxing-jx-geo-code>00</avp-taxing-jx-geo-code>
      <avp-taxing-jx-county>031</avp-taxing-jx-county>
      <transfer-to-state-code>GA</transfer-to-state-code>
      <ship-to-taxware-geo>146017900</ship-to-taxware-geo>
    </tax-reference>
  </purchase-order>
  <purchase-order>
    <customer-order-confirmation-number>650637713</customer-order-confirmation-number>
    <customer-email>bx2vzj_16q8lboz_67@seller.sears.com</customer-email>
    <po-number>408306533</po-number>
    <po-date>2014-10-02</po-date>
    <po-time>05:22:59</po-time>
    <po-number-with-date>20141002408306533</po-number-with-date>
    <unit>9300</unit>
    <site>SEARS</site>
    <channel>DSS</channel>
    <location-id>8446</location-id>
    <expected-ship-date>2014-09-09</expected-ship-date>
    <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>3400 ParkWay RD</address>
      <city>CONCORD</city>
      <state>GA</state>
      <zipcode>30206</zipcode>
      <phone>7703311985</phone>
      <shipping-method>Ground</shipping-method>
      <carrier>UPS</carrier>
    </shipping-detail>
    <customer-name>John Doe</customer-name>
    <po-line>
      <po-line-header>
        <line-number>1</line-number>
        <item-id>12321</item-id>
        <item-name>DSS Item1</item-name>
        <unit-cost>44.62</unit-cost>
        <!-- Unit Cost included only for DSS orders -->
        <selling-price-each>51.29</selling-price-each>
        <unit-sales-tax>1.86</unit-sales-tax>
        <commission>6.67</commission>
        <order-quantity>1</order-quantity>
        <shipping-and-handling>8.95</shipping-and-handling>
        <unit-shipping-tax>0.00</unit-shipping-tax>
      </po-line-header>
      <po-line-detail>
        <po-line-status>NEW</po-line-status>
        <quantity>1</quantity>
      </po-line-detail>
    </po-line>
    <order-total-sell-price>51.29</order-total-sell-price>
    <total-commission>6.67</total-commission>
    <total-shipping-handling>8.95</total-shipping-handling>
    <balance-due>53.57</balance-due>
    <sales-tax>1.86</sales-tax>
    <po-status>New</po-status>
    <tax-reference>
      <delivery-tax-code>1</delivery-tax-code>
      <tax-rate>14260</tax-rate>
      <avp-taxing-jx-geo-code>00</avp-taxing-jx-geo-code>
      <avp-taxing-jx-county>031</avp-taxing-jx-county>
      <transfer-to-state-code>VA</transfer-to-state-code>
      <ship-to-taxware-geo>146017900</ship-to-taxware-geo>
    </tax-reference>
  </purchase-order>
  <purchase-order>
    <customer-order-confirmation-number>650637714</customer-order-confirmation-number>
    <customer-email>bx2vzj_16q8lboz_67@seller.sears.com</customer-email>
    <po-number>408306534</po-number>
    <po-date>2014-10-02</po-date>
    <po-time>05:22:59</po-time>
    <po-number-with-date>20141002408306534</po-number-with-date>
    <unit>9300</unit>
    <site>SEARS</site>
    <channel>DSS</channel>
    <location-id>8446</location-id>
    <expected-ship-date>2014-09-09</expected-ship-date>
    <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>3400 ParkWay RD</address>
      <city>CONCORD</city>
      <state>GA</state>
      <zipcode>30206</zipcode>
      <phone>7703311985</phone>
      <shipping-method>Other</shipping-method>
      <carrier>OTH</carrier>
    </shipping-detail>
    <customer-name>John Doe</customer-name>
    <po-line>
      <po-line-header>
        <line-number>1</line-number>
        <item-id>12321</item-id>
        <item-name>DSS Item</item-name>
        <unit-cost>14.29</unit-cost>
        <!-- Unit Cost included only for DSS orders -->
        <selling-price-each>16.81</selling-price-each>
        <unit-sales-tax>1.86</unit-sales-tax>
        <commission>2.52</commission>
        <order-quantity>1</order-quantity>
        <shipping-and-handling>8.95</shipping-and-handling>
        <unit-shipping-tax>0.65</unit-shipping-tax>
      </po-line-header>
      <po-line-detail>
        <po-line-status>NEW</po-line-status>
        <quantity>1</quantity>
      </po-line-detail>
    </po-line>
    <order-total-sell-price>16.81</order-total-sell-price>
    <total-commission>2.52</total-commission>
    <total-shipping-handling>8.95</total-shipping-handling>
    <balance-due>23.24</balance-due>
    <sales-tax>1.86</sales-tax>
    <po-status>New</po-status>
    <tax-reference>
      <delivery-tax-code>1</delivery-tax-code>
      <tax-rate>14260</tax-rate>
      <avp-taxing-jx-geo-code>00</avp-taxing-jx-geo-code>
      <avp-taxing-jx-county>031</avp-taxing-jx-county>
      <transfer-to-state-code>GA</transfer-to-state-code>
      <ship-to-taxware-geo>146017900</ship-to-taxware-geo>
    </tax-reference>
  </purchase-order>
  <purchase-order>
    <customer-order-confirmation-number>650637715</customer-order-confirmation-number>
    <customer-email>bx2vzj_16q8lboz_67@seller.sears.com</customer-email>
    <po-number>408306535</po-number>
    <po-date>2014-10-02</po-date>
    <po-time>05:22:59</po-time>
    <po-number-with-date>20141002408306535</po-number-with-date>
    <unit>9301</unit>
    <site>SEARS</site>
    <channel>FBM</channel>
    <location-id>8446</location-id>
    <expected-ship-date>2014-09-09</expected-ship-date>
    <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>3400 ParkWay RD</address>
      <city>CONCORD</city>
      <state>GA</state>
      <zipcode>30206</zipcode>
      <phone>7703311985</phone>
      <shipping-method>Next Day Saver</shipping-method>
    </shipping-detail>
    <customer-name>John Doe</customer-name>
    <po-line>
      <po-line-header>
        <line-number>1</line-number>
        <item-id>12321</item-id>
        <item-name>EOS  Ultra  Moisturizing  Cream</item-name>
        <selling-price-each>1.49</selling-price-each>
        <unit-sales-tax>0.00</unit-sales-tax>
        <commission>0.13</commission>
        <order-quantity>1</order-quantity>
        <shipping-and-handling>8.95</shipping-and-handling>
        <unit-shipping-tax>0.00</unit-shipping-tax>
      </po-line-header>
      <po-line-detail>
        <po-line-status>NEW</po-line-status>
        <quantity>1</quantity>
      </po-line-detail>
    </po-line>
    <order-total-sell-price>1.49</order-total-sell-price>
    <total-commission>0.13</total-commission>
    <total-shipping-handling>8.95</total-shipping-handling>
    <balance-due>10.31</balance-due>
    <sales-tax>0.10</sales-tax>
    <po-status>New</po-status>
    <tax-reference>
      <delivery-tax-code>1</delivery-tax-code>
      <tax-rate>14260</tax-rate>
      <avp-taxing-jx-geo-code>00</avp-taxing-jx-geo-code>
      <avp-taxing-jx-county>031</avp-taxing-jx-county>
      <transfer-to-state-code>GA</transfer-to-state-code>
      <ship-to-taxware-geo>146017900</ship-to-taxware-geo>
    </tax-reference>
  </purchase-order>
  <purchase-order>
    <customer-order-confirmation-number>650637716</customer-order-confirmation-number>
    <customer-email>bx2vzj_16q8lboz_67@seller.sears.com</customer-email>
    <po-number>408306536</po-number>
    <po-date>2014-10-02</po-date>
    <po-time>05:22:59</po-time>
    <po-number-with-date>20141002408306536</po-number-with-date>
    <unit>9300</unit>
    <site>SEARS</site>
    <channel>DSS</channel>
    <location-id>8446</location-id>
    <expected-ship-date>2014-09-09</expected-ship-date>
    <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>3400 ParkWay RD</address>
      <city>CONCORD</city>
      <state>GA</state>
      <zipcode>30206</zipcode>
      <phone>7703311985</phone>
      <shipping-method>Priority Mail</shipping-method>
      <carrier>USPS</carrier>
    </shipping-detail>
    <customer-name>John Doe</customer-name>
    <po-line>
      <po-line-header>
        <line-number>1</line-number>
        <item-id>12321</item-id>
        <item-name>EOS  Ultra  Moisturizing  Sensitive  Shave  Cream  by  EOS  7.0  oz  Fragrance  Free  Shave  Cream</item-name>
        <unit-cost>0.90</unit-cost>
        <selling-price-each>0.99</selling-price-each>
        <unit-sales-tax>0.09</unit-sales-tax>
        <commission>0.09</commission>
        <order-quantity>1</order-quantity>
        <shipping-and-handling>8.95</shipping-and-handling>
        <unit-shipping-tax>0.00</unit-shipping-tax>
      </po-line-header>
      <po-line-detail>
        <po-line-status>SHIPPED</po-line-status>
        <quantity>1</quantity>
      </po-line-detail>
    </po-line>
    <order-total-sell-price>0.99</order-total-sell-price>
    <total-commission>0.09</total-commission>
    <total-shipping-handling>8.95</total-shipping-handling>
    <balance-due>9.85</balance-due>
    <sales-tax>0.09</sales-tax>
    <po-status>Ready to Invoice</po-status>
    <!-- This status will show while invoice is getting ready, Once invoice created po-status will flip to Closed status and  shipping details which includes shipping Carrier name and tracking number will show.
      Refer Order#408306532 reference-->
    <tax-reference>
      <delivery-tax-code>1</delivery-tax-code>
      <tax-rate>14260</tax-rate>
      <avp-taxing-jx-geo-code>00</avp-taxing-jx-geo-code>
      <avp-taxing-jx-county>031</avp-taxing-jx-county>
      <transfer-to-state-code>GA</transfer-to-state-code>
      <ship-to-taxware-geo>146017900</ship-to-taxware-geo>
    </tax-reference>
  </purchase-order>
  <purchase-order>
    <customer-order-confirmation-number>650637716</customer-order-confirmation-number>
    <customer-email>bx2vzj_16q8lboz_67@seller.sears.com</customer-email>
    <po-number>408306537</po-number>
    <po-date>2014-10-02</po-date>
    <po-time>05:22:59</po-time>
    <po-number-with-date>20141002408306537</po-number-with-date>
    <unit>9300</unit>
    <site>SEARS</site>
    <channel>DSS</channel>
    <location-id>8446</location-id>
    <expected-ship-date>2014-09-09</expected-ship-date>
    <shipping-detail>
      <ship-to-name>John Doe</ship-to-name>
      <address>3400 ParkWay RD</address>
      <city>CONCORD</city>
      <state>GA</state>
      <zipcode>30206</zipcode>
      <phone>7703311985</phone>
      <shipping-method>Priority Mail</shipping-method>
      <carrier>USPS</carrier>
    </shipping-detail>
    <customer-name>John Doe</customer-name>
    <po-line>
      <po-line-header>
        <line-number>1</line-number>
        <item-id>12321</item-id>
        <item-name>DSS Item</item-name>
        <unit-cost>182.59</unit-cost>
        <!-- Unit Cost included only for DSS orders -->
        <selling-price-each>219.99</selling-price-each>
        <unit-sales-tax>16.05</unit-sales-tax>
        <commission>37.40</commission>
        <order-quantity>1</order-quantity>
        <shipping-and-handling>8.95</shipping-and-handling>
      </po-line-header>
      <po-line-detail>
        <po-line-status>NEW</po-line-status>
        <quantity>1</quantity>
      </po-line-detail>
    </po-line>
    <order-total-sell-price>219.99</order-total-sell-price>
    <total-commission>37.40</total-commission>
    <total-shipping-handling>8.95</total-shipping-handling>
    <balance-due>191.54</balance-due>
    <sales-tax>16.05</sales-tax>
    <po-status>New</po-status>
    <tax-reference>
      <delivery-tax-code>1</delivery-tax-code>
      <tax-rate>14260</tax-rate>
      <avp-taxing-jx-geo-code>00</avp-taxing-jx-geo-code>
      <avp-taxing-jx-county>031</avp-taxing-jx-county>
      <transfer-to-state-code>GA</transfer-to-state-code>
      <ship-to-taxware-geo>146017900</ship-to-taxware-geo>
    </tax-reference>
  </purchase-order>
</po-response>

我得到了大小为0的PurchaseOrder。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

purchase-order元素不是XmlArray,因此如果您更改此属性,

[Serializable]
[XmlRoot(ElementName = "po-response", Namespace = "http://seller.marketplace.sears.com/oms/v11")]
public class SearsPurchaseOrderResponseModel
{
    [XmlElement("deprecated")]
    public DateTime Deprecated { get; set; }

    [Required]
    // [XmlArrayItem("purchase-order")]
    [XmlElement("purchase-order")]
    public List<SearsPurchaseOrderModel> PurchaseOrder { get; set; }
}

然后反序列化的对象(XmlResponse)将在列表中包含一些PurchaseOrder个实例。