У меня есть сторонний документ wsdl и я пытаюсь сериализовать запрос в XML.
Я выяснил, что некоторые значения (например, PaymentType), которые были установлены для экземпляра объекта, не сериализуются. Другие делают (как PersonName).
Что может быть причиной такой проблемы и как ее исправить?
Проблема не в самом XML, хотя он генерируется прокси. Похоже, на предыдущем шаге должна быть другая причина или какая-то настройка.
Вот пример:
И XML-классы стороннего сервиса.
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://fedex.com/ws/rate/v24")]
public partial class CustomsClearanceDetail {
private BrokerDetail[] brokersField;
private ClearanceBrokerageType clearanceBrokerageField;
private bool clearanceBrokerageFieldSpecified;
private CustomsOptionDetail customsOptionsField;
private Party importerOfRecordField;
private RecipientCustomsId recipientCustomsIdField;
private Payment dutiesPaymentField;
private InternationalDocumentContentType documentContentField;
private bool documentContentFieldSpecified;
private Money customsValueField;
private FreightOnValueType freightOnValueField;
private bool freightOnValueFieldSpecified;
private Money insuranceChargesField;
private bool partiesToTransactionAreRelatedField;
private bool partiesToTransactionAreRelatedFieldSpecified;
private CommercialInvoice commercialInvoiceField;
private Commodity[] commoditiesField;
private ExportDetail exportDetailField;
private RegulatoryControlType[] regulatoryControlsField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Brokers")]
public BrokerDetail[] Brokers {
get {
return this.brokersField;
}
set {
this.brokersField = value;
}
}
/// <remarks/>
public ClearanceBrokerageType ClearanceBrokerage {
get {
return this.clearanceBrokerageField;
}
set {
this.clearanceBrokerageField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool ClearanceBrokerageSpecified {
get {
return this.clearanceBrokerageFieldSpecified;
}
set {
this.clearanceBrokerageFieldSpecified = value;
}
}
/// <remarks/>
public CustomsOptionDetail CustomsOptions {
get {
return this.customsOptionsField;
}
set {
this.customsOptionsField = value;
}
}
/// <remarks/>
public Party ImporterOfRecord {
get {
return this.importerOfRecordField;
}
set {
this.importerOfRecordField = value;
}
}
/// <remarks/>
public RecipientCustomsId RecipientCustomsId {
get {
return this.recipientCustomsIdField;
}
set {
this.recipientCustomsIdField = value;
}
}
/// <remarks/>
public Payment DutiesPayment {
get {
return this.dutiesPaymentField;
}
set {
this.dutiesPaymentField = value;
}
}
/// <remarks/>
public InternationalDocumentContentType DocumentContent {
get {
return this.documentContentField;
}
set {
this.documentContentField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool DocumentContentSpecified {
get {
return this.documentContentFieldSpecified;
}
set {
this.documentContentFieldSpecified = value;
}
}
/// <remarks/>
public Money CustomsValue {
get {
return this.customsValueField;
}
set {
this.customsValueField = value;
}
}
/// <remarks/>
public FreightOnValueType FreightOnValue {
get {
return this.freightOnValueField;
}
set {
this.freightOnValueField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool FreightOnValueSpecified {
get {
return this.freightOnValueFieldSpecified;
}
set {
this.freightOnValueFieldSpecified = value;
}
}
/// <remarks/>
public Money InsuranceCharges {
get {
return this.insuranceChargesField;
}
set {
this.insuranceChargesField = value;
}
}
/// <remarks/>
public bool PartiesToTransactionAreRelated {
get {
return this.partiesToTransactionAreRelatedField;
}
set {
this.partiesToTransactionAreRelatedField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool PartiesToTransactionAreRelatedSpecified {
get {
return this.partiesToTransactionAreRelatedFieldSpecified;
}
set {
this.partiesToTransactionAreRelatedFieldSpecified = value;
}
}
/// <remarks/>
public CommercialInvoice CommercialInvoice {
get {
return this.commercialInvoiceField;
}
set {
this.commercialInvoiceField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Commodities")]
public Commodity[] Commodities {
get {
return this.commoditiesField;
}
set {
this.commoditiesField = value;
}
}
/// <remarks/>
public ExportDetail ExportDetail {
get {
return this.exportDetailField;
}
set {
this.exportDetailField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("RegulatoryControls")]
public RegulatoryControlType[] RegulatoryControls {
get {
return this.regulatoryControlsField;
}
set {
this.regulatoryControlsField = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://fedex.com/ws/rate/v24")]
public partial class Payment {
private PaymentType paymentTypeField;
private bool paymentTypeFieldSpecified;
private Payor payorField;
/// <remarks/>
public PaymentType PaymentType {
get {
return this.paymentTypeField;
}
set {
this.paymentTypeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool PaymentTypeSpecified {
get {
return this.paymentTypeFieldSpecified;
}
set {
this.paymentTypeFieldSpecified = value;
}
}
/// <remarks/>
public Payor Payor {
get {
return this.payorField;
}
set {
this.payorField = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://fedex.com/ws/rate/v24")]
public enum PaymentType {
/// <remarks/>
SENDER,
}