2
私のWCFメッセージから値を取得する必要があります。XmlDictionaryReaderを使用してメッセージから値を取得する
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IBrokerService/SaveAndPrint</Action>
</s:Header>
<s:Body>
<SaveAndPrint xmlns="http://tempuri.org/">
<contract xmlns:d4p1="http://schemas.datacontract.org/2004/07/BrokerService.Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:ContainerHistoryContracts i:nil="true" />
<!--Lots of nodes removed for brevity-->
<d4p1:CurrentBagId>123456</d4p1:CurrentBagId>
<!--Lots more nodes removed for brevity-->
<d4p1:WorkStation>TheNeededValue</d4p1:WorkStation>
</contract>
</SaveAndPrint>
</s:Body>
</s:Envelope>
しかし、私は、私はd4p1:WorkStation
値を取得するためにXmlDictionaryReaderを使用することはできません可能性があるとみてください:私のメッセージは、デバッガで次の値を持っています。誰もXmlDictionaryReaderを使ってこれを行う方法を知っていますか?
注:私はTypedMessageConverter
を使用しようとしましたが、clasessはMessageContract
の属性を持っていない生成
アップデート(彼らはDataContract
かかわらを持っています):私は動作しませんが何をしています。しかし包み、あなたがそれを見たいと思って、ここにある:
// Load the message into an xml doc
var navigator = buffer.CreateNavigator();
MemoryStream memoryStream = new MemoryStream();
XmlWriter xmlWriter = XmlWriter.Create(memoryStream);
navigator.WriteSubtree(xmlWriter);
xmlWriter.Flush();
xmlWriter.Close();
memoryStream.Position = 0;
XDocument xdoc = XDocument.Load(XmlReader.Create(memoryStream));
var workstationElement =
xdoc.Descendants(XName.Get("StringValue",
@"/s:Envelope[@xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/""]/s:Body/SaveAndPrint[@xmlns=""http://tempuri.org/""]/contract[@xmlns:d4p1=""http://schemas.datacontract.org/2004/07/BrokerService.Contracts""]/d4p1:WorkStation"));
あなたのXML解析コードは何に見えますか? – DVK
@DVK - 壊れたコードがどのように役立つかわからないけど、それを追加しました。 – Vaccano