用java2wsdl生成的Web服务是否可以包含来自多个Java类的API? [英] Could the web service generated with `java2wsdl` include API from more than one Java class?

查看:66
本文介绍了用java2wsdl生成的Web服务是否可以包含来自多个Java类的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Axis2运行Web服务.这是定义服务的services.xml文件:

I am using Axis2 to run a web service. Here is a services.xml file that defines a service:

<service name="XEWS" scope="transportsession" class="com.mc.xews.XEWS">
<messageReceivers>
    <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
    <messageReceiver  mep="http://www.w3.org/2004/08/wsdl/in-out"  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceClass" locked="false">com.mc.xews.XEWS</parameter>

我的问题是整个API位于单个Java文件XEWS.java中,并且此类被发送到java2wsdl.有没有一种方法可以将多个类输入java2wsdl?此文件与WSDL一起使用以生成Web服务.现在,我仅使用一个类作为java2wsdl的输入,因此该类变得非常大,因为有许多API函数...如果我知道如何将多个文件发送到java2wsdl,则可以将它们很好地分组到单独的类中.从此类生成的JavaDocs文档也很难阅读.

My problem is that the whole API is located in one single Java file XEWS.java and this class is sent to java2wsdl. Is there a way to have more than one class as input to java2wsdl? This file is used with WSDL to generate web service. Right now I use only one class as input to java2wsdl, so this class became huge, since there is many API functions.... that could be nicely grouped in separate classes if I knew how to send more than one file to java2wsdl. JavaDocs documentation generated from this class is also hard to read.

该Web服务是否可以包含来自多个Java类的API?

Could the web service include API from more than one Java class?

也许应该使用java2wsdl中的extra classes选项参数吗?

Is maybe extra classes option parameter from java2wsdl supposed to be used for this?

推荐答案

否,这是不可能的,因为Axis2生成工具以代码优先方式将Java类:WSDL映射为1:1.假设地,他们本可以提供将多个Java类映射到单个WSDL的功能(这将需要在生成工具中添加其他参数).

No, this is not possible as Axis2 generation tool maps Java class : WSDL as 1:1 in a code-first approach. Hypothetically, they could have provided feature to map multiple Java classes to a single WSDL (that would require additional parameters in generation tool).

Axis2将额外类"用于其他类型-原始复杂类型的子类用作输入/输出.

Axis2 uses 'extra classes' for additional types - subclasses of original complex types used as input/output.

如果整洁而紧凑的代码是唯一的问题,我建议将其重构为只有一个类定义所有必需的操作,但是将执行委派给特定的&适当的(多个)类.可以将其视为外观模式的应用.

If neat and compact code is the only issue, I would suggest refactoring it the way that only one single class defines all the required operations, but delegates execution to specific & appropriate (multiple) classes. This can be considered as an application of a Façade pattern.

这篇关于用java2wsdl生成的Web服务是否可以包含来自多个Java类的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆