首页 新闻 会员 周边 捐助

Serializer.XMLToObject<CMBSDKPGKResponse>序列化问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-04-08 15:31

在使用Serializer.XMLToObject<CMBSDKPGKResponse>(result);

时异常:

捕捉到 System.InvalidOperationException
HResult=-2146233079
Message=XML 文档(1, 38)中有错误。
Source=System.Xml
StackTrace:
在 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
在 System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
在 JDD.Bank.CMBFbSdk.Common.Serializer.XMLToObject[T](String source) 位置 d:\Program\CMBFbSdk\CMBFbSdk\JDD.Bank.CMBFbSdk\Common\Serializer.cs:行号 71
在 JDD.Bank.CMBFbSdk.CMBRule.JDDBankRule.CMBPay(CMBSDKPGKRequest cmbreqEntity) 位置 d:\Program\CMBFbSdk\CMBFbSdk\JDD.Bank.CMBFbSdk\CMBRule\JDDBankRule.cs:行号 672
InnerException: System.InvalidOperationException
HResult=-2146233079
Message=不应有 <CMBSDKPGK xmlns=''>。
Source=Microsoft.GeneratedCode
StackTrace:
在 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderCMBSDKPGKResponse.Read5_Msg()

CMBSDKPGKResponse实体我是用xsd生成的。

CMBSDKPGK是返回xml的最外层节点。

  1 namespace JDD.Bank.CMBFbSdk.CMBEntity
  2 {
  3     using System.Xml.Serialization;
  4     /// <remarks/>
  5     [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
  6     [System.SerializableAttribute()]
  7     [System.Diagnostics.DebuggerStepThroughAttribute()]
  8     [System.ComponentModel.DesignerCategoryAttribute("code")]
  9     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "")]
 10     [System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false, ElementName = "Msg")]
 11     public partial class CMBSDKPGKResponse
 12     {
 13 
 14         private INFO iNFOField;
 15 
 16         private NTQPAYRQZ[] nTQPAYRQZField;
 17 
 18         /// <remarks/>
 19         [XmlElement("INFO")]
 20         public INFO INFO
 21         {
 22             get { return this.iNFOField; }
 23             set { this.iNFOField = value; }
 24         }
 25 
 26         /// <remarks/>
 27         //[System.Xml.Serialization.XmlArrayItemAttribute(IsNullable = false)]
 28         [XmlElement("NTQPAYRQZ")]
 29         public NTQPAYRQZ[] NTQPAYRQZ
 30         {
 31             get { return this.nTQPAYRQZField; }
 32             set { this.nTQPAYRQZField = value; }
 33         }
 34     }
 35 
 36 
 37     /// <remarks/>
 38     [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
 39     [System.SerializableAttribute()]
 40     [System.Diagnostics.DebuggerStepThroughAttribute()]
 41     [System.ComponentModel.DesignerCategoryAttribute("code")]
 42     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "")]
 43     public partial class INFO
 44     {
 45 
 46         private string fUNNAMField;
 47 
 48         private string dATTYPField;
 49 
 50         private string rETCODField;
 51 
 52         private string eRRMSGField;
 53 
 54         private string lGNNAMField;
 55 
 56         public string LGNNAM
 57         {
 58             get { return this.lGNNAMField; }
 59             set { this.lGNNAMField = value; }
 60         }
 61         /// <remarks/>
 62         public string FUNNAM
 63         {
 64             get { return this.fUNNAMField; }
 65             set { this.fUNNAMField = value; }
 66         }
 67 
 68         /// <remarks/>
 69         public string DATTYP
 70         {
 71             get { return this.dATTYPField; }
 72             set { this.dATTYPField = value; }
 73         }
 74 
 75         /// <remarks/>
 76         public string RETCOD
 77         {
 78             get { return this.rETCODField; }
 79             set { this.rETCODField = value; }
 80         }
 81 
 82         /// <remarks/>
 83         public string ERRMSG
 84         {
 85             get { return this.eRRMSGField; }
 86             set { this.eRRMSGField = value; }
 87         }
 88     }
 89 
 90     /// <remarks/>
 91     [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
 92     [System.SerializableAttribute()]
 93     [System.Diagnostics.DebuggerStepThroughAttribute()]
 94     [System.ComponentModel.DesignerCategoryAttribute("code")]
 95     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true,
 96         Namespace = "")]
 97     public partial class NTQPAYRQZ
 98     {
 99 
100         private string sQRNBRField;
101 
102         private string yURREFField;
103 
104         private string rEQNBRField;
105 
106         private string rEQSTSField;
107 
108         private string rTNFLGField;
109 
110         private string oPRSQNField;
111 
112         private string oPRALSField;
113 
114         private string eRRCODField;
115 
116         private string eRRTXTField;
117 
118         /// <remarks/>
119         public string SQRNBR
120         {
121             get { return this.sQRNBRField; }
122             set { this.sQRNBRField = value; }
123         }
124 
125         /// <remarks/>
126         public string YURREF
127         {
128             get { return this.yURREFField; }
129             set { this.yURREFField = value; }
130         }
131 
132         /// <remarks/>
133         public string REQNBR
134         {
135             get { return this.rEQNBRField; }
136             set { this.rEQNBRField = value; }
137         }
138 
139         /// <remarks/>
140         public string REQSTS
141         {
142             get { return this.rEQSTSField; }
143             set { this.rEQSTSField = value; }
144         }
145 
146         /// <remarks/>
147         public string RTNFLG
148         {
149             get { return this.rTNFLGField; }
150             set { this.rTNFLGField = value; }
151         }
152 
153         /// <remarks/>
154         public string OPRSQN
155         {
156             get { return this.oPRSQNField; }
157             set { this.oPRSQNField = value; }
158         }
159 
160         /// <remarks/>
161         public string OPRALS
162         {
163             get { return this.oPRALSField; }
164             set { this.oPRALSField = value; }
165         }
166 
167         /// <remarks/>
168         public string ERRCOD
169         {
170             get { return this.eRRCODField; }
171             set { this.eRRCODField = value; }
172         }
173 
174         /// <remarks/>
175         public string ERRTXT
176         {
177             get { return this.eRRTXTField; }
178             set { this.eRRTXTField = value; }
179         }
180     }
181 }
View Code

请大侠解答啊

_劍客的主页 _劍客 | 初学一级 | 园豆:94
提问于:2014-04-04 10:56
< >
分享
所有回答(1)
0

ElementName = "Msg"很关键,先将实体做序列化xml,与已有的做比较一眼可以发现问题。

_劍客 | 园豆:94 (初学一级) | 2014-04-08 15:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册