Question

Is it possible to split a web service in to multiple classes and still provide a single path to the web service?

I know this isn't possible because of the duplicate url-pattern values. It sort of illustrates where we're wanting to go :)

<endpoint name="OneBigService"
          implementation="SmallImpl1"
          url-pattern="/OneBigService"/>

<endpoint name="OneBigService"
          implementation="SmallImpl2"
          url-pattern="/OneBigService"/>

Basically, how do avoid having one monolithic @WebService class?

Thanks!

Rob

Was it helpful?

Solution

Is it possible to split a web service in to multiple classes and still provide a single path to the web service?

No. A URI is a connection point to one web service (defined by the Port/Endpoint).

Basically, how do avoid having one monolithic @WebService class?

Well, in my opinion the real question is more when should I use several Port/Endpoint? And I would be tempted to answer: regroup/split things logically.

For example, while it make sense for a Calculator service to expose add, subtract, multiply and divide operations, I would use another service to expose a getQuote operation.

Now, you can always split the logic into several classes and delegate to them from your @WebService.

OTHER TIPS

You could delegate functionality to a composed class from your web service class:

@WebService
public class OneBigService {
    ISmall delegate = new SmallImpl1(); // or new SmallImpl2();

    @WebMethod
    public Result webMethodStuff() {
        // do something with delegate
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top