【发布时间】:2019-12-10 20:06:46
【问题描述】:
我没有很多使用 XSD 文件或 SOAP 的经验,如果这是一个微不足道的请求,我很抱歉。
我正在构建一个应用程序以通过 Quickbooks Web 连接器与 Quickbooks Desktop 进行通信,并且我需要我的 Web 服务在调用 authentication(strUserName, strPassword) 时返回一个字符串数组。
我正在使用 XJC 插件从 XSD 文件中创建我的 Java POJO 类,仅供参考。
我目前的 XSD 响应定义格式如下:
<xsd:element name="authenticateResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="authenticateResult" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
我也试过这样格式化:
<xsd:element name="authenticateResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="authenticateResult">
<xsd:simpleType>
<xsd:list itemType="xsd:string"/>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
我的 Spring 服务器正在返回对方法的调用,如下所示:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:authenticateResponse xmlns:ns2="http://developer.intuit.com/">
<ns2:authenticateResult>291bc0f2-b22b-40b7-9326-8bb946cf91ca</ns2:authenticateResult>
<ns2:authenticateResult/>
</ns2:authenticateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但我需要像这样返回它们:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://developer.intuit.com/">
<SOAP-ENV:Body>
<ns1:authenticateResponse>
<ns1:authenticateResult>
<ns1:string>15c9ce293bd3f41b761c21635b14fa06</ns1:string>
<ns1:string></ns1:string>
</ns1:authenticateResult>
</ns1:authenticateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
注意:父对象应为'ns2:authenticateResult',其子对象应为'ns2:string'作为元素。
我怎样才能让它正确返回?
【问题讨论】:
标签: java spring xsd quickbooks xjc