Could the web service generated with `java2wsdl` include API from more than one Java class?

谁说胖子不能爱 提交于 2019-12-01 12:16:18

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.

In WSDL the largest namespace is the service itself (it's methods are the smallest). WSDL doesn't support nested namespaces. The most logical mapping between Java and WSDL is the Java Class to the WSDL Service. This is what makes your request to pass multiple Java Classes to get a single WSDL impossible. You can always host more than one WSDL but you still have to generate those separately.

Quoting the w3c:

Related concrete endpoints are combined into abstract endpoints (services)

There is an IMPORT mechanism to combine WSDLs but this is seen as a single service to the WSDL2Java (or any other SOAP client) so the it would still represent a single service.

If you are worried about the size of the implementation, just look at PayPal's web service.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!