【发布时间】:2014-07-03 16:52:00
【问题描述】:
我有这样的肥皂消息:
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<ShipNo_Check xmlns="http://bimgewebservices.gmb.gov.tr">
<shipNo>13343100VB0000000014</shipNo>
<harborNo>1234567</harborNo>
</ShipNo_Check>
</s:Body>
</s:Envelope>
在我的 asp.net mvc 应用程序中,我需要序列化这个 xml。我正在使用这种方法:
public object SoapTo(string soapString) {
IFormatter formatter;
MemoryStream memStream = null;
Object objectFromSoap = null;
try {
byte[] bytes = new byte[soapString.Length];
Encoding.ASCII.GetBytes(soapString, 0,
soapString.Length, bytes, 0);
memStream = new MemoryStream(bytes);
formatter = new SoapFormatter();
objectFromSoap = formatter.Deserialize(memStream);
}
catch (Exception exception) {
throw exception;
}
finally {
if (memStream != null) memStream.Close();
}
return objectFromSoap;
}
我收到以下错误:
Parse Error, no assembly associated with Xml key _P1 ShipNo_Check
我怎样才能做到这一点?
【问题讨论】:
-
您拥有的 XML 无效:打开标签
<harborNo>被</tasitNo>关闭。 -
我在复制粘贴时犯了错误。我已经编辑了我的问题。
标签: c# soap deserialization