我在解析下面的soap响应时遇到了问题。这是我第一次使用LINQ,并且必须使用XML而不是SOAP信封。我如何获取不同“项目”的值。我知道有不同的选项(使用添加服务引用),但它不是我当前项目中的一个选项。用LINQ解析肥皂响应
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:ns1=\"http://random.com/api/1/service\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:ns2=\"http://xml.apache.org/xml-soap\"
xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"
SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">
<SOAP-ENV:Body>
<ns1:getBeatlesResponse>
<return xsi:type=\"ns2:Map\">
<item>
<key xsi:type=\"xsd:string\">error</key>
<value xsi:type=\"xsd:string\">OK</value>
</item>
<item>
<key xsi:type=\"xsd:string\">Beatles</key>
<value xsi:type=\"ns2:Map\">
<item>
<key xsi:type=\"xsd:int\">9</key>
<value xsi:type=\"xsd:string\">John Lennon</value>
</item>
<item>
<key xsi:type=\"xsd:int\">12</key>
<value xsi:type=\"xsd:string\">Paul McCartney</value>
</item>
<item>
<key xsi:type=\"xsd:int\">25</key>
<value xsi:type=\"xsd:string\">George Harrison</value>
</item>
<item>
<key xsi:type=\"xsd:int\">184</key>
<value xsi:type=\"xsd:string\">Ringo Starr</value>
</item>
</value>
</item>
</return>
</ns1:getBeatlesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
在此先感谢
非常感谢!这样做的工作,但我觉得很奇怪多少复杂性带来了其他属性里面的同名其属性时......我想真正的解决方案将改变属性名称,但我不参与开发的Web服务 – retain 2011-04-17 01:19:24
问题是,如果它会像和- ...那么它可能会更好...那么它会很容易...因为每个
你确切知道哪些子元素属于它,你不必作弊:) –
2011-04-17 05:39:50