读取xsi格式的XML文件 [英] Reading XML file in xsi format

查看:111
本文介绍了读取xsi格式的XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何读取文件:-----



how to read file:-----



<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-

instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <SOAP-ENV:Header>
                        <TransactionId>0079185000400624</TransactionId>
                        <TraceId>36221056</TraceId>
            </SOAP-ENV:Header>
            <SOAP-ENV:Body>
                        <ns1:bookreservationResponse xmlns:ns1="urn:os:bookreservation:v2" SOAP-



ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
                                    <return xsi:type="ns1:BookReservationResponse">
                                                <SessionID xsi:type="xsd:string">0079185000400624</SessionID>
                                                <ResultCode xsi:type="xsd:int">0</ResultCode>
                                                <Exceptions xmlns:ns2="http://xml.apache.org/xml-soap" xsi:type="ns2:Vector">
                                                </Exceptions>
                                                <Pnr xsi:type="ns1:PassengerNameRecord">
                                                            <Remarks xmlns:ns3="http://xml.apache.org/xml-soap"



xsi:type="ns3:Vector">
                                                            </Remarks>
                                                            <CreateDateTime xsi:type="xsd:dateTime">2010-01-

13T12:25:44.000Z</CreateDateTime>
                                                            <Exceptions xmlns:ns4="http://xml.apache.org/xml-soap"



xsi:type="ns4:Vector">
                                                            </Exceptions>
                                                            <ModifyDateTime xsi:type="xsd:dateTime" xsi:nil="true"/>
                                                            <Status xsi:type="xsd:string">PN</Status>
                                                            <PNRId xsi:type="xsd:string">JZ7KBD</PNRId>
                                                            <AltPNRId xsi:type="xsd:string"></AltPNRId>
                                                            <CreateUser xsi:type="xsd:string">API0S</CreateUser>
                                                            <ModifyUser xsi:type="xsd:string"></ModifyUser>
                                                </Pnr>
                                                <TransactionID xsi:type="xsd:string">0079185000400624</TransactionID>
                                    </return>
                        </ns1:bookreservationResponse>
            </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


:〜

推荐答案

好,这不是xsi格式,而是SOAP格式.

如果需要的话,您将像阅读其他任何XML文档一样阅读它. 但是通常不需要这样做.正常情况下,有一个与Web服务关联的WSDL文件,您所需要做的就是针对服务WSDL文件运行WSDL.exe,它会生成与服务对话的代理类和对象模型类,以将XML反序列化为对象.在这种情况下,AFACT将获得一个BookReservation对象(自从我使用香草SOAP服务以来已经很长时间了),其属性设置为XML中的值.

这将节省您手动编写代理的大量工作.请参阅此以获取有关使用WSDL的文章:
http://my.execpc.com/~gopalan/dotnet/webservices/webservice_csharp_client.html [^ ]
OK, this isn''t xsi format, it is SOAP format.

If you had to, you''d read it like any other XML Document. However there is normally no need to do this. Normall there is a WSDL file associated with a web service, all you need to do is run WSDL.exe against the services WSDL file, and it generates proxy classes to talk to the service and Object model classes to deserialize the XML to objects. In this case AFACT, you''ll get a BookReservation object (its been a long time since I used vanilla SOAP Services), with properties set to the values in the XML.

This will save you a lot of work hand-rolling your own proxies. See this for an article about using the WSDL:
http://my.execpc.com/~gopalan/dotnet/webservices/webservice_csharp_client.html[^]


这篇关于读取xsi格式的XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆