开发者

Possible to split one JAX-WS service across multiple source files?

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 illus开发者_如何学Pythontrates 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


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.


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
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜