【问题标题】:How to create a retrofit soap request object with schema in it?如何创建一个带有模式的改造肥皂请求对象?
【发布时间】:2017-05-25 21:18:58
【问题描述】:

我有一个请求 xml,其中包含架构定义。如何创建需要传递给 retrofit 肥皂请求的 pojo 类。

下面是我的示例 xml 需要创建为 pojo 的数据

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soap:Header />
<soap:Body>
    <gbr xmlns="http://tempuri.org/">
        <objhandler>
            <id>
                <int>123</int>
            </id>
            <dp>true</dp>
            <cid>12312</cid>
        </objhandler>
        <dtASNCondensed>
            <xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" id="NewDataSet" xmlns="">
                <xs:element name="NewDataSet" msdata:IsDataSet="true"
                    msdata:MainDataTable="dtASNCondensed" msdata:UseCurrentLocale="true">
                    <xs:complexType>
                        <xs:choice maxOccurs="unbounded" minOccurs="0">
                            <xs:element name="dtASNCondensed">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="id" minOccurs="0" type="xs:string" />
                                        <xs:element name="gid" minOccurs="0" type="xs:string" />
                                        <xs:element name="te" minOccurs="0" type="xs:string" />
                                        <xs:element name="rec" minOccurs="0" type="xs:string" />
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:choice>
                    </xs:complexType>
                </xs:element>
            </xs:schema>
            <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
                xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
                <DocumentElement xmlns="">
                    <dtASNCondensed diffgr:hasChanges="inserted" diffgr:id="dtASNCondensed1"
                        msdata:rowOrder="0">
                        <id>123</id>
                        <gid>3000037430</gid>
                        <te>102</te>
                        <rec>1</rec>
                    </dtASNCondensed>
                </DocumentElement>
            </diffgr:diffgram>
        </dtASNCondensed>
    </gbr>
</soap:Body>

【问题讨论】:

    标签: java android xml soap retrofit2


    【解决方案1】:

    你可以用简单的 xml 库来做,你可以像这样构建你的改造

    retrofit =  new Retrofit.Builder()
            .addConverterFactory(SimpleXmlConverterFactory.create(serializer))
            .baseUrl("http://www.webservicex.net/")
            .client(okHttpClient)
            .build();
    

    更多细节你可以查看这个例子https://github.com/asanchezyu/RetrofitSoapSample

    【讨论】:

    • 嗨 Krutik,我的应用程序已经启动并运行,并实施了改造。我的问题是为有问题的 xml 创建一个请求对象。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-19
    • 1970-01-01
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多