【发布时间】:2015-02-15 15:02:17
【问题描述】:
我正在使用 JAX-WS 2.2.5 框架来调用 WebServices。我想确定调用失败时的特殊情况,因为 Web 服务已关闭或无法访问。
在某些调用中,我得到一个 WebServiceException。
catch(javax.xml.ws.WebServiceException e)
{
if(e.getCause() instanceof IOException)
if(e.getCause().getCause() instanceof ConnectException)
// Will reach here because the Web Service was down or not accessible
在其他地方,我得到 ClientTransportException(从 WebServiceException 派生的类)
catch(com.sun.xml.ws.client.ClientTransportException ce)
{
if(ce.getCause() instanceof ConnectException)
// Will reach here because the Web Service was down or not accessible
捕获此错误的好方法是什么?
我应该使用类似的东西
catch(javax.xml.ws.WebServiceException e)
{
if((e.getCause() instanceof ConnectException) || (e.getCause().getCause() instanceof ConnectException))
{
// Webservice is down or inaccessible
或者有更好的方法吗?
【问题讨论】:
标签: java web-services exception-handling jax-ws webservices-client