我需要解析XML文档作为当前脱机的webservice的返回值。所以我想在等待它的可用性时创建一个外观。这是一个示例:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:AD90B9C079ED11E3BF6E3900E216CC13</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
<wsa:ReferenceParameters>
<instra:tracking.ecid xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">cd42df45b193f389:55338234:143243fa919:-8000-0000000000432eda</instra:tracking.ecid>
</wsa:ReferenceParameters>
</wsa:ReplyTo>
<wsa:FaultTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
<wsa:ReferenceParameters>
<instra:tracking.ecid xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">cd42df45b193f389:55338234:143243fa919:-8000-0000000000432eda</instra:tracking.ecid>
</wsa:ReferenceParameters>
</wsa:FaultTo>
</env:Header>
<env:Body>
<db:BancosDbOutput xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/recuperaBancosDb">
<db:recuperaBancosDbOutput>
<db:nomeBanco>BANCO ABC BRASIL S.A.</db:nomeBanco>
<db:numeroBanco>246</db:numeroBanco>
<db:pais>Brasil</db:pais>
</db:recuperaBancosDbOutput>
<db:recuperaBancosDbOutput>
<db:nomeBanco>BANCO A.J.RENNER S.A.</db:nomeBanco>
<db:numeroBanco>654</db:numeroBanco>
<db:pais>Brasil</db:pais>
</db:recuperaBancosDbOutput>
</db:BancosDbOutput>
</env:Body>
</env:Envelope>
我得到了这个服务WSDL和XSD文件,我用WSDL.exe
生成了代理,但我无法反序列化对该webservice代理对象的响应。当我尝试这样的事情时,我通常得到SerializationException: Parse Error, no assembly associated with Xml key
:
private bool SOAPDeserialize<T>(string filePath, out T ClassObj)
{
using(FileStream fs = new FileStream(filePath, FileMode.Open))
{
try
{
SoapFormatter soap = new SoapFormatter();
soap.AssemblyFormat = FormatterAssemblyStyle.Simple;
ClassObj = (T) soap.Deserialize(fs);
}
catch (SerializationException ex)
{
ClassObj = default(T);
return false;
}
}
return true;
}
你是否有任何关于如何做到这一点的线索?