我正在尝试创建返回 vo 列表的网络服务。我能够返回 VO 列表。但我需要特定方式的 xml 结构。
我不知道如何使用 eclipse Axis 。
我的配置
- eclipse 3.4
- Java 1.6
- Axis 运行时间
- Tomcat 6
我的VO结构
看VO
名称:字符串
编号:字符串
我在 web 服务类中有方法 getGroupLookVO
为此我得到一个返回 xml 作为
<getGroupLookVOResponse>
<getGroupLookVOReturn>
<name>one</name>
<id>1</id>
</getGroupLookVOReturn>
<getGroupLookVOReturn>
<name>two</name>
<id>2</id>
</getGroupLookVOReturn>
<getGroupLookVOReturn>
<name>three</name>
<id>3</id>
</getGroupLookVOReturn>
</getGroupLookVOResponse>
我需要的xml结构是
<getGroupLookVOResponse>
<getGroupLookVOReturn>
<LookVO>
<name>one</name>
<id>1</id>
</LookVO>
<LookVO>
<name>two</name>
<id>2</id>
</LookVO>
<LookVO>
<name>three</name>
<id>3</id>
</LookVO>
</getGroupLookVOReturn>
</getGroupLookVOResponse>
方法签名是
public LookVO[] getGroupLookVO()
我尝试编辑 wsdl,但是一旦我重新生成客户端,wsdl 就会被重写。我也不擅长 WSDl。
有人能帮我指出正确的方向吗
最佳答案
如果我有你的问题,你应该重新生成之前的 web 服务,而不是客户端。
1) 更改 WEBSERVICE 中的方法(不是在客户端中!)以获得您需要的行为
2) 右击你的 WS 包然后 New -> Other -> Web Services -> Web Service
3) 按照向导添加所有你想发布的方法
4) 在服务器上部署你的网络服务
然后
5) 从新的 wsdl 重新生成客户端
只是个人言论,但这是一个品味问题。在 XML 中,同一个列表中元素顺序的概念不应该存在,因为通过 XML 模式的验证不提供这种可能性。您可以按照您想要的顺序生成元素,但如果您是精心设计的 XML 的“纯粹主义者”,则不应依赖同一列表中标记的顺序。但是,我不想在这件事上太烦人:))
关于java - 更改 JAVA Axis Web 服务响应 XML 正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11849149/