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>
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.
Could the web service include API from more than one Java class?
Is maybe extra classes option parameter from java2wsdl supposed to be used for this?
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 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.