简体   繁体   中英

why void return method and throws no exception methods are not considered as one way operation by default in jax-ws?

I know that jaxws 2.2 specification says that all public non-static non-final method on a SEI which does not have WebMethod annotation with exclude as true , should be mapped to wsdl:operation elements.

It also says only the methods annotated with javax.jws.OneWay must be oneway operation , if the method does not have OneWay annotation (even if it has void return type and no exception ) MUST NOT be mapped to oneway operation s.

I don't find any reason to prevent void returning method with no exception mapping to oneway operation as default. This arises another question. why do we even need OneWay annotation when any method with void return type and no exception is oneway operation ?

any method with void return type and no exception is oneway operation

This is not true. By default, void return type and no declared checked exception method is standard operation.

By default, client thread invoking a service will wait until receiving response from server (or client will timeout). Standard webservice operation, even with void return type, will respond with SOAP response (with empty body) after processing web method operation. It's synchronous invocation by default.

For example, if you have void type WebMethod with time consuming operation, service client will wait until all processing at server side is finished (assuming that no timeout occured), or will receive RuntimeException from server in case of fault. This will not happen with @OneWay operation.

In case of @OneWay methods, they are invoked asynchronously, so client thread will not wait for finishing server web method operations, and will proceed immediately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM