WCF在响应中反序列化XML

时间:2018-09-19 14:41:17

标签: xml wcf soap datacontractserializer

我从服务获得以下SOAP响应...

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <GetSomethingResponse xmlns="http://namespace/services">
         <GetSomethingResult xmlns:a="http://namespace/model" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

         <a:SomethingData>

         <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
            <Persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <Person>
                <Name>John Doe</Name>
              </Person>
              <Person>
                <Name>Jane Doe</Name>
              </Person>
            </Persons>]]>

            </a:SomethingData>

            <a:ExampleProperty1>0</a:ExampleProperty1>
            <a:ExampleProperty2>0</a:ExampleProperty2>
            <a:ExampleProperty3>0</a:ExampleProperty3>

         </GetSomethingResult>
      </GetSomethingResponse>
   </s:Body>
</s:Envelope>

SomethingDataExampleProperty1ExampleProperty2ExampleProperty3都是来自WSDL的字符串数据类型。

有什么办法可以告诉DataContractSerializer自动反序列化SomethingData中的XML?

0 个答案:

没有答案