了解JAX-WS中的@Oneway批注 [英] Understanding @Oneway annotation in JAX-WS

查看:78
本文介绍了了解JAX-WS中的@Oneway批注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个javadoc:

指示给定的@WebMethod仅具有输入消息,而没有输出.通常,单向方法在执行实际业务方法之前将控制线程返回到调用应用程序.如果标记为@Oneway的操作具有返回值或Holder参数,或者声明任何已检查的异常,则181处理器应报告错误.

Indicates that the given @WebMethod has only an input message and no output. Typically, a oneway method returns the thread of control to the calling application prior to executing the actual business method. A 181 processor should report an error if an operation marked @Oneway has a return value or Holder parameters, or declares any checked exceptions.

那么我是否可以假设,如果我需要异常处理(选中或未选中),则不建议使用此批注?我没有从业务逻辑中返回任何信息,但是我仍然对了解超时和其他各种特定于调用SOAP方法的错误感兴趣.此注释是否表示我无权访问HTTP返回码或引发异常?

Can I assume then, that if I need exception handling (checked or unchecked) that this annotation is not recommended ? I don't return anything from the business logic, however I still have an interest in being aware of timeouts and other various errors specific to act of calling a SOAP method. Does this annotation mean I don't have access to HTTP return codes or thrown exceptions ?

问题:我最好还是自己单独处理这个线程,以获得真正的异步调用,并删除@Oneway批注?

Question: Am I better off threading this out on my own to get a truly asynchronous call, and removing the @Oneway annotation ?

推荐答案

@Oneway意味着什么都不会转义您的方法,无论是响应还是异常.这有两个原因:

@Oneway means nothing will ever escape your method, neither response nor exception. This is for two reasons:

  • 技术上的异常只是响应的另一种类型(SOAP错误),因此无法从单向方法(无法返回任何内容)返回它

  • technically exception is just another type of response (SOAP fault), thus it cannot be returned from a one-way method (which can't return anything)

通常由Web服务框架异步执行单向方法(我知道

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆