Miscellaneous recipes
The following miscellaneous recipes do not fit into any obvious category.
Custom fault handling
There are a variety of ways that SOAP faults can be handled. They can cause the operation to abort, then cause the current document to fail, or they can generate an "application error". The WSExecuteOperation defers this decision to the WSConnection, where it can be easily customized.
To ensure that failures abort the current operation, do the following:
- Extend the
WSConnectionclass, override theisFatalException()method, and include logic for determining whether an exception is fatal.
Code sample
@Override
public boolean isFatalException(Throwable t)
{
if(t instanceof MyAuthenticationException) {
return true;
}
return false;
}
To choose whether a SOAP fault is an application error or a failure, do the following:
- Extend the
WSConnectionclass, override theisApplicationFault()method, and include logic for determining whether a fault is an application error.
Code sample
@Override
public boolean isApplicationFault(WebServiceResponse wsResponse)
{
if(MY_APPLICATION_UKNOWN_ERROR_CODE.equals(wsResponse.getFaultCode())) {
return false;
}
return true;
}
Was this topic helpful?