[英]Array of object parameter in Java Webservice Provider
根据WSDL,我的提供程序必须具有一个对象数组作为输入参数:
<element name="classifica" type="Q4:Titolario" maxOccurs="unbounded" minOccurs="0"/>
这是生成的方法:
public void protoModificaProtocollo(...,...,...,Titolario[] classifica,....) {
如何获取此数组的输入值(始终返回null)。
编辑
这是要提供的方法的xsd模式:
<import schemaLocation="TipoVerso.xsd" namespace="http://regione.toscana.it/rfc205/interpro.TipoVerso"/>
<import schemaLocation="Anagrafica.xsd" namespace="http://regione.toscana.it/rfc205/interpro.Anagrafica"/>
<import schemaLocation="Titolario.xsd" namespace="http://regione.toscana.it/rfc205/interpro.Titolario"/>
<element name="protoModificaProtocolloElement" type="tns:protoModificaProtocollo"/>
<complexType name="protoModificaProtocollo">
<sequence>
<element name="numero" type="int" maxOccurs="1" minOccurs="1"/>
<element name="anno" type="int" maxOccurs="1" minOccurs="1"/>
<element name="verso" type="Q1:TipoVerso" maxOccurs="1" minOccurs="1"/>
<element name="oggetto" type="string" maxOccurs="1" minOccurs="0"/>
<element name="classifica" type="Q4:Titolario" maxOccurs="unbounded" minOccurs="0"/>
<element name="ufficio" type="Q2:Anagrafica" maxOccurs="unbounded" minOccurs="0"/>
</sequence>
</complexType>
这是Titolario的xsd模式
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://regione.toscana.it/rfc205/interpro.Titolario"
elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://regione.toscana.it/rfc205/interpro.Titolario">
<complexType name="Titolario">
<sequence>
<element name="codice" type="string" maxOccurs="1" minOccurs="1"></element>
<element name="descrizione" type="string" maxOccurs="1" minOccurs="0">
</element>
</sequence>
</complexType>
</schema>
这里发送了SOAP消息:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:int="http://regione.toscana.it/rfc205/interpro"
xmlns:int1="http://regione.toscana.it/rfc205/interpro.protoModificaProtocollo"
xmlns:int2="http://regione.toscana.it/rfc205/interpro.Titolario"
xmlns:int3="http://regione.toscana.it/rfc205/interpro.Anagrafica">
<soapenv:Header/>
<soapenv:Body>
<int:protoModificaProtocollo>
<int1:numero>140</int1:numero>
<int1:anno>2014</int1:anno>
<int1:verso>P</int1:verso>
<!--Optional:-->
<int1:oggetto>test</int1:oggetto>
<!--Zero or more repetitions:-->
<int1:classifica>
<int2:codice>34</int2:codice>
<!--Optional:-->
<int2:descrizione>test description</int2:descrizione>
</int1:classifica>
</int:protoModificaProtocollo>
</soapenv:Body>
</soapenv:Envelope>
在提供程序中,这是方法:
public void protoModificaProtocollo(int numero, int anno, TipoVerso verso,
String oggetto, Titolario[] classificazione, Anagrafica[] ufficio,
ResponseProtocolloHolder protocollo_resp, ResponseErrorHolder response_msg_err) {
... some stuff here ...
System.out.println("getCodice():" + classificazione[0].getCodice()); <-- THIS LINE ALWAYS RETURNS NULL
请注意,在输入参数中,如果我更改
Titolario[] classificazione
同
Titolario classificazione
我的调试行打印:
34
更新2
TIA Simon,在这里pastebin可以找到完整的WSDL。 这里的Titolario.java是Titolario的类。 我注意到,当消费者调用提供者,Titolario构造函数调用N次时,具体取决于SOAP请求中Titolario出现的次数。 如您所见,该构造函数是一个空的构造函数。
在这一刻,我的协议是RPC /编码的,因为我必须理解这里报告的问题Literal vs Encoded (如果您也可以看一下... :-)
我发现了一些有关该问题的参考,例如本文 ,可能与我的有关。
无论如何,我想知道是否有Java解决方法来管理它。 再次感谢!
发现了问题!
事实是,我已经使用相同的给定WSDL来生成提供程序和创建SoapUI项目。
基本上,诀窍是:
<soap:body use="literal"/>
指令设置RPC/Literal
而已! ...一个非常愚蠢的错误! :-(
没有完整的WSDL,我不能100%地说这是问题。
根据您到目前为止的情况。
1.使用自定义字符串处理程序包装“ xsd:string”存在一些已知问题。 我在“字符串”位于“ xsd:string”顶部之前已经看到了引用。 因此,我首先将其更改回“ xsd:string”,看看是否有帮助。
2.由于您的Web服务提供商具有以下优势:
Titolario[] classifica
通常,您的WSDL应该创建使用者发送的xxxArray
对象,而不是数组对象本身。 (在Doc / Literal + RPC / Literal上进行了测试,因为“ minoccurs”仅显示在Literal上)。
例如:
public String TestProtoModificaProtocollo (Titolario x[]) { ...
转换为:
<complexType name="Titolario">
<sequence>
<element name="codice" nillable="true" type="xsd:string"/>
<element maxOccurs="unbounded" minOccurs="0" name="descrizione" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="TitolarioArray">
<sequence>
<element maxOccurs="unbounded" minOccurs="0" name="item" type="impl:Titolario"/>
</sequence>
</complexType>
<element name="x" type="impl:TitolarioArray"/>
<element name="TestProtoModificaProtocolloReturn" type="xsd:string"/>
因此,您的消费者将转换为:
public java.lang.String testProtoModificaProtocollo(TitolarioArray x) throws java.rmi.RemoteException;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.