Search code examples
javawsdljax-ws

2 WSDL's or 2 portTypes which solution is better?


I am curious about what Java developers are thinking about having 2 WSDLs.

Recently we were asked to expand an existing web service. After some research I find out that we can extend the existing web service WSDL with 2 (different/name) portTypes. The advantage is that we do not have to generate java code twice from 2 different WSDLs in the same application and maintaining 2 different WSDLs.

My question is which solution is advantageous 2 WSDL's or 2 PortType in the same (existing) WSDL?


Solution

  • Maybe this can also help someone else.

    To begin with, I always prefer to expand an existing wsdl with an extra portType. Unless it concerns other kind of information where there is a clear separation like Sales/Shipping.

    Because it is common to have a wsdl with one portType, I found some examples on the internet with more then two portTypes. CXF: Implement multiple ports on same soap:adress?

    But this solution was not that simple for me because of JAX-WS. And I found the solution with 2 portTypes in the WSDL.

    As prescribed by JSR-109, the default URL pattern is constructed using the @WebService.serviceName attribute (2 portTypes also, means 2 same serviceName derived urls's)

    Step 1 WSDL:

    enter image description here

    Step 2 web.xml

    enter image description here

    Platforms like Tomcat this can offer a solution with 2 portTypes

    JAX-WS multiple endpoints in sun-jaxws.xml