急求助,第一个回答出来的50分全送!
<Request>
<streamingNo></streamingNo>
<opFlag></opFlag>
<productID></productID>
<serviceID></serviceID>
<SPID></SPID>
<chargingPolicyID></chargingPolicyID>
<status></status>
<statusEffectiveTime></statusEffectiveTime>
<chargingPolicyCN></chargingPolicyCN>
<chargingPolicyEN></chargingPolicyEN>
<corpOnly></corpOnly>
<releaseTime></releaseTime>
<subscriptionSyncFlag></subscriptionSyncFlag>
<needCnfm></needCnfm>
<packageFlag></packageFlag>
<portalUseFlag></portalUseFlag>
<sellFlag></sellFlag>
<productDesc></productDesc>
<CRBTProductType></CRBTProductType>
<accessNoAndfeatureStr>
<accessNo></accessNo>
<accessNoMatchMode></accessNoMatchMode>
<accessNoType></accessNoType>
<featureStr></featureStr>
<featureStrType></featureStrType>
<featureStrMatchMode></featureStrMatchMode>
</accessNoAndfeatureStr>
<RRID></RRID>
<productName></productName>
<trialFlag></trialFlag>
<subEffectMode></subEffectMode>
<PayType></PayType>
<isTrailInPeriod></isTrailInPeriod>
</Request>
这个是一个WS的字符串请求,我要怎么写才能将这个请求反序列化成类
我自己的代码:
XmlSerializer xs = new XmlSerializer(typeof(ProductInfoReqObject));
TextReader tr = new StringReader(ProductInfoReq.Request);
ProductInfoReqObject request = (ProductInfoReqObject)xs.Deserialize(tr);
会提示:XML 文档(1, 4)中有错误。 在 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
在 System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
在 IsmpVnetEngine.ISMPVnetEngine.IsmpVnetEngine.IIsmpVnetEngineSoapBinding.vnetProductInfo(VnetProductInfoReq vnetProductInfoReq)
------解决方案--------------------
------解决方案--------------------
你的xml文件中的节点和ProductInfoReqObject类中的字段不匹配啊!!
还有要按序列化的xml文件的格式必须是:
XML code
<?xml version="1.0"?>
<ProductInfoReqObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<streamingNo>aaa</streamingNo>
<opFlag>e</opFlag>
.......
</ProductInfoReqObject>