0

We are using a web service which throws 3 types of custom web service faults i.e. ServiceException, ConnectionException and InvalidDataException.

Along with these catch blocks, we have also put in the catch block for RemoteAccessException which is the spring's runtime exception.

catch (org.springframework.remoting.RemoteAccessException remoteAccessExc) {
}

While testing the above listed custom exceptions, we found that all these 3 types of exceptions are not getting catched in their respective catch blocks. Instead all gets catched in the last catch block which is the RemoteAccessException. We found during debugging the exception object of soap fault which is of type org.springframework.remoting.jaxws.JaxWsSoapFaultException that the service is throwing the correct faults.

My concern is why these faults are not falling into their own catch blocks. The service itself tells us to handle these exceptions while placing the service call.

When I hit the service through proxy java client, the faults fall correctly into their respective blocks. If there would have been a problem with POJO's then they shouldn't have worked in this case also. But they are working in this case(when hit through java proxy client) which means no problem in POJOs.

We are using spring-2.5.6.jar.

4

1 回答 1

0

由于您保留不同的 catch 块并且故障对象被覆盖,请执行以下操作:

检查每个 catch 块中的故障对象是否为空,以便在抛出故障时,它不会在任何其他 catch 块中被覆盖。这是因为您在 catch 块的每个条目上都进行了非空检查。

try{
    //////
}Catch(IllegalArgumentException e){
    create fault object;
    throw fault;    
}
Catch(Exception e){
    ///check whether fault object is not null

    if(fault!=null){
    throw fault;
}else{
    ///another fault object 
    throw fault1;
}
于 2012-08-30T08:36:37.983 回答