我们使用轴工具开发了一个Web服务。但我们无法获得非常正确的退货模式,任何建议或帮助都将受到赞赏。这是我们使用复杂类型的第一个服务。我不知道它是否重要,但是正在开发这个部署在Liferay 6.1中。
[更新]我想我开始明白响应中的元素名称是基于getter的。由于getChildAccounts(),响应包含元素。但是数组元素的getter只是get()或者更确切地说没有一个,只有Account [#]。所以也许它会回到它拥有的最后一个元素名称。如何控制/覆盖此行为?
Java模型是
Account
-ChildAccounts which is a Account[]
以下是相关的xml注释:
帐户:
package com.lightpath.it.netcracker.rmi.model;
public class Account {
protected BigInteger accountNumber;
protected String name;
protected BigInteger objectId;
protected Account[] childAccounts;
public BigInteger getAccountNumber() {
return accountNumber;
}
public Account[] getChildAccounts() {
return childAccounts;
}
public String getName() {
return name;
}
public BigInteger getObjectId() {
return objectId;
}
...
WSDD
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Plugin_lp_rmi_AccountService" provider="java:RPC" style="rpc" use="encoded">
<arrayMapping xmlns:ns="urn:http.service.rmi.netcracker.it.lightpath.com" xmlns:cmp-ns="http://model.rmi.netcracker.it.lightpath.com" qname="ns:ArrayOf_tns2_Account" type="java:com.lightpath.it.netcracker.rmi.model.Account[]" innerType="cmp-ns:Account" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></arrayMapping>
<typeMapping xmlns:ns="http://model.rmi.netcracker.it.lightpath.com" qname="ns:Account" type="java:com.lightpath.it.netcracker.rmi.model.Account" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></typeMapping>
<typeMapping xmlns:ns="http://model.rmi.netcracker.it.lightpath.com" qname="ns:AccountResponse" type="java:com.lightpath.it.netcracker.rmi.model.AccountResponse" serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></typeMapping>
<operation xmlns:operNS="urn:http.service.rmi.netcracker.it.lightpath.com" xmlns:rtns="http://model.rmi.netcracker.it.lightpath.com" name="createAccountInNC" qname="operNS:createAccountInNC" returnQName="createAccountInNCReturn" returnType="rtns:AccountResponse" soapAction="">
<parameter xmlns:tns="http://www.w3.org/2001/XMLSchema" qname="accountNo" type="tns:string"></parameter>
<parameter xmlns:tns="http://www.w3.org/2001/XMLSchema" qname="accountName" type="tns:string"></parameter>
<parameter xmlns:tns="http://www.w3.org/2001/XMLSchema" qname="parentAccObjId" type="tns:integer"></parameter>
</operation>
<operation xmlns:operNS="urn:http.service.rmi.netcracker.it.lightpath.com" xmlns:rtns="http://model.rmi.netcracker.it.lightpath.com" name="fetchAccountHierarchy" qname="operNS:fetchAccountHierarchy" returnQName="fetchAccountHierarchyReturn" returnType="rtns:AccountResponse" soapAction="">
<parameter xmlns:tns="http://www.w3.org/2001/XMLSchema" qname="accountNo" type="tns:string"></parameter>
</operation>
<parameter name="allowedMethods" value="createAccountInNC fetchAccountHierarchy" />
<parameter name="className" value="com.lightpath.it.netcracker.rmi.service.http.AccountServiceSoap" />
<parameter name="schemaUnqualified" value="http://model.rmi.netcracker.it.lightpath.com,urn:http.service.rmi.netcracker.it.lightpath.com" />
<parameter name="typeMappingVersion" value="1.2" />
<parameter name="wsdlPortType" value="AccountServiceSoap" />
<parameter name="wsdlServiceElement" value="AccountServiceSoapService" />
<parameter name="wsdlServicePort" value="Plugin_lp_rmi_AccountService" />
<parameter name="wsdlTargetNamespace" value="urn:http.service.rmi.netcracker.it.lightpath.com" />
</service>
</deployment>
预期的响应模式应为:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:fetchAccountHierarchyResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:http.service.rmi.netcracker.it.lightpath.com">
<fetchAccountHierarchyReturn xsi:type="ns2:AccountResponse" xmlns:ns2="http://model.rmi.netcracker.it.lightpath.com">
<account xsi:type="ns2:Account">
<accountNumber xsi:type="soapenc:integer" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">45836</accountNumber>
<childAccounts soapenc:arrayType="ns2:Account[10]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<account xsi:type="ns2:Account">
<accountNumber xsi:type="soapenc:integer">45330</accountNumber>
<childAccounts soapenc:arrayType="ns2:Account[0]" xsi:type="soapenc:Array"/>
<name xsi:type="soapenc:string">XXXXXXX (XXX BUILDING)</name>
<objectId xsi:type="soapenc:integer">9134381813913466316</objectId>
</account>
<account xsi:type="ns2:Account">
<accountNumber xsi:type="soapenc:integer">45331</accountNumber>
<childAccounts soapenc:arrayType="ns2:Account[0]" xsi:type="soapenc:Array"/>
<name xsi:type="soapenc:string">XXXXXXXX (XXX BUILDING)</name>
<objectId xsi:type="soapenc:integer">9134381813913466315</objectId>
</account>
</childAccounts>
<name xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">XXXXXXX</name>
<objectId xsi:type="soapenc:integer" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">9134381813913466398</objectId>
</account>
</fetchAccountHierarchyReturn>
</ns1:fetchAccountHierarchyResponse>
</soapenv:Body>
</soapenv:Envelope>
但这是我们得到的:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:fetchAccountHierarchyResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:http.service.rmi.netcracker.it.lightpath.com">
<fetchAccountHierarchyReturn xsi:type="ns2:AccountResponse" xmlns:ns2="http://model.rmi.netcracker.it.lightpath.com">
<account xsi:type="ns2:Account">
<accountNumber xsi:type="soapenc:integer" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">45836</accountNumber>
<childAccounts soapenc:arrayType="ns2:Account[10]" xsi:type="soapenc:Array" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<childAccounts xsi:type="ns2:Account">
<accountNumber xsi:type="soapenc:integer">45330</accountNumber>
<childAccounts soapenc:arrayType="ns2:Account[0]" xsi:type="soapenc:Array"/>
<name xsi:type="soapenc:string">XXXXXXX (XXX BUILDING)</name>
<objectId xsi:type="soapenc:integer">9134381813913466316</objectId>
</childAccounts>
<childAccounts xsi:type="ns2:Account">
<accountNumber xsi:type="soapenc:integer">45331</accountNumber>
<childAccounts soapenc:arrayType="ns2:Account[0]" xsi:type="soapenc:Array"/>
<name xsi:type="soapenc:string">XXXXXXXX (XXX BUILDING)</name>
<objectId xsi:type="soapenc:integer">9134381813913466315</objectId>
</childAccounts>
</childAccounts>
<name xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">XXXXXXX</name>
<objectId xsi:type="soapenc:integer" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">9134381813913466398</objectId>
</account>
</fetchAccountHierarchyReturn>
</ns1:fetchAccountHierarchyResponse>
</soapenv:Body>
</soapenv:Envelope>
子帐户元素有两个元素而不是。我尝试过修改WSDD和XML注释,但无法改变。