C# 部分反序列化ASMX服务XML请求
首先,我想说我知道这项古老的技术,如果由我决定,生活将会不同。我对这项老技术比较陌生,我正在扩展现有的工作服务,我遇到了一个奇怪的问题。我有3个服务端点,其中2个按预期工作,但第三个服务端点的问题是“框架”无法反序列化xml请求C# 部分反序列化ASMX服务XML请求,c#,xml,web-services,wcf,asmx,C#,Xml,Web Services,Wcf,Asmx,首先,我想说我知道这项古老的技术,如果由我决定,生活将会不同。我对这项老技术比较陌生,我正在扩展现有的工作服务,我遇到了一个奇怪的问题。我有3个服务端点,其中2个按预期工作,但第三个服务端点的问题是“框架”无法反序列化xml请求 <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http:/
<?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>
1.
1.
1_8
asdf
11
123
123
扎尔
30
N
1.
1.
1.
50
0
自助式早餐
123
123
上面是xml,netCredentials被正确反序列化,但p_objrequest为null
如果你经历过这个问题并解决了它,如果你能引导我走向正确的方向,我将不胜感激
提前谢谢
编辑
下面是课堂
[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;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute(“svcutil”,“4.6.1055.0”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“代码”)]
[System.Xml.Serialization.XmlTypeAttribute(命名空间=”http://tokenws.netgen.co.za/")]
公务舱销售
{
私有int事务类型字段;
私人国际招标类型字段;
私有请求StandardHeaderComponent standardHeaderField;
私有帐户组件accountField;
私有字符串字段;
私有amount组件amountField;
私有customerinfoc组件customerInfoField;
私人促销代码[]促销代码字段;
私人问题和回答[]问题和回答字段;
私有行项目[]行项目字段;
私有字符串includeTipField;
///
[System.Xml.Serialization.XmlElementAttribute(顺序=0)]
公共int事务类型ID
{
得到
{
返回此.TransactionTypedField;
}
设置
{
this.transactionTypeIdField=值;
}
}
///
[System.Xml.Serialization.XmlElementAttribute(顺序=1)]
公共int tenderTypeId
{
得到
{
返回此.tenderTypedField;
}
设置
{
this.tenderTypeIdField=值;
}
}
///
[System.Xml.Serialization.XmlElementAttribute(顺序=2)]
公共请求standardHeader组件standardHeader
{
得到
{
返回此.standardHeaderField;
}
设置
{
this.standardHeaderField=值;
}
}
///
[System.Xml.Serialization.XmlElementAttribute(顺序=3)]
公共帐户组成帐户
{
得到
{
返回此.accountField;
}
设置
{
this.accountField=值;
}
}
///
[System.Xml.Serialization.XmlElementAttribute(顺序=4)]
公共字符串激活
{
得到
{
返回此.activatingField;
}
设置
{
this.activatingField=值;
}
}
///
[System.Xml.Serialization.XmlElementAttribute(顺序=5)]
公共金额构成金额
{
得到
{
返回此.amountField;
}
设置
{
this.amountField=值;
}
}
///
[System.Xml.Serialization.XmlElementAttribute(顺序=6)]
公共customerInfo组件customerInfo
{
得到
{
返回此.customerInfoField;
}
设置
{
this.customerInfoField=值;
}
}
///
[System.Xml.Serialization.XmlArrayAttribute(Order=7)]
公共促销代码[]促销代码
{
得到
{
返回此.promotionCodesField;
}
设置
{
this.promotionCodesField=值;
}
}
///
[System.Xml.Serialization.XmlArrayAttribute(Order=8)]
公开问题与答案[]问题与答案
{
得到
{
返回此.questions和answersfield;
}
设置
{
this.questions和answersfield=值;
}
}
///
[System.Xml.Serialization.XmlArrayAttribute(Order=9)]
公共行项目[]行项目
{
得到
{
返回此.lineItems字段;
}
设置
{
this.lineItemsField=值;
}
}
///
[System.Xml.Serialization.XmlElementAttribute(顺序=10)]
公共字符串includeTip
{
得到
{
返回此.includeTipField;
}
设置
{
this.includeTipField=值;
}
}
}
标记名和类/属性名必须匹配,包括大小写。见下文:
[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;}
}
这可能没什么,但你试过改变顺序吗?将
密码
置于用户名
之前