我知道这个老技术,如果由我决定,生活会有所不同。我对这项旧技术相对较新,我正在扩展工作中现有的服务,并且遇到了一个奇怪的问题。我有 3 个服务端点,其中 2 个按预期工作,但我对第三个的问题是"框架"无法反序列化 xml 请求。
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<UpdateSale xmlns="http://tokenws.netgen.co.za/">
<p_objrequest>
<transactionTypeId>1</transactionTypeId>
<tenderTypeId>1</tenderTypeId>
<standardHeader>
<requestId xmlns="">1_8</requestId>
<localeId xmlns="" />
<systemId xmlns="">asdf</systemId>
<batchReference xmlns="">11</batchReference>
</standardHeader>
<account>
<accountId xmlns="">123</accountId>
<pin xmlns="" >123</pin>
</account>
<amount>
<valueCode xmlns="">ZAR</valueCode>
<enteredAmount xmlns="">30</enteredAmount>
<nsfAllowed xmlns="">N</nsfAllowed>
</amount>
<lineItems>
<LineItem>
<productCode>1</productCode>
<categoryCode>1</categoryCode>
<qty>1</qty>
<price>50</price>
<discountedPrice>0</discountedPrice>
<description>Buffet Breakfast</description>
</LineItem>
</lineItems>
</p_objrequest>
<netCredentials>
<UserName xmlns="http://tempuri.org/">123</UserName>
<Password xmlns="http://tempuri.org/">123</Password>
</netCredentials>
</UpdateSale>
</soap:Body>
</soap:Envelope>
上面是xml,netCredentials被正确反序列化,但p_objrequest为空。
我该如何解决这个问题?
以下是课程:
[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tokenws.netgen.co.za/")]
public class Sale
{
private int transactionTypeIdField;
private int tenderTypeIdField;
private RequestStandardHeaderComponent standardHeaderField;
private AccountComponent accountField;
private string activatingField;
private AmountComponent amountField;
private CustomerInfoComponent customerInfoField;
private PromotionCode[] promotionCodesField;
private QuestionAndAnswer[] questionsAndAnswersField;
private LineItem[] lineItemsField;
private string includeTipField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 0)]
public int transactionTypeId
{
get
{
return this.transactionTypeIdField;
}
set
{
this.transactionTypeIdField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 1)]
public int tenderTypeId
{
get
{
return this.tenderTypeIdField;
}
set
{
this.tenderTypeIdField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 2)]
public RequestStandardHeaderComponent standardHeader
{
get
{
return this.standardHeaderField;
}
set
{
this.standardHeaderField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 3)]
public AccountComponent account
{
get
{
return this.accountField;
}
set
{
this.accountField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 4)]
public string activating
{
get
{
return this.activatingField;
}
set
{
this.activatingField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 5)]
public AmountComponent amount
{
get
{
return this.amountField;
}
set
{
this.amountField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 6)]
public CustomerInfoComponent customerInfo
{
get
{
return this.customerInfoField;
}
set
{
this.customerInfoField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Order = 7)]
public PromotionCode[] promotionCodes
{
get
{
return this.promotionCodesField;
}
set
{
this.promotionCodesField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Order = 8)]
public QuestionAndAnswer[] questionsAndAnswers
{
get
{
return this.questionsAndAnswersField;
}
set
{
this.questionsAndAnswersField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Order = 9)]
public LineItem[] lineItems
{
get
{
return this.lineItemsField;
}
set
{
this.lineItemsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 10)]
public string includeTip
{
get
{
return this.includeTipField;
}
set
{
this.includeTipField = value;
}
}
}
标记名称和类/属性名称必须匹配,包括大小写。 见下文 :
[XmlRoot(ElementName= "UpdateSale", Namespace="http://tokenws.netgen.co.za/")]
public class Sale
{
}
[XmlRoot(ElementName= "netCredentials")]
public class NetCredentials
{
[XmlElement(ElementName="UserName",Namespace="http://tempuri.org/")]
public Name userName { get; set;}
[XmlElement(ElementName="Password",Namespace="http://tempuri.org/")]
public Name password { get; set;}
}
public class Name
{
[XmlText]
public string name { get; set;}
}