0

We have a legacy SOAP web service written in .Net. We are rewriting that now in java.

I have never worked on SOAP services but have a little knowledge in REST web services.

In Jax RS, we have ExceptionMapper interface, which can be used to map any RuntimeException to a Response. So we map our custom exceptions and java.lang.RuntimeException to handle any unhandled runtime exceptions like below

@Provider
public class UnhandledExceptionMapper implements ExceptionMapper<RuntimeException> { ... }

This way we make sure no exception stack trace will be returned to the client.

Is there a similar approach in Jax WS?

Krishna Chaitanya
  • 2,533
  • 4
  • 40
  • 74
  • Possible duplicate of [How to throw a custom fault on a JAX-WS web service?](http://stackoverflow.com/questions/13596260/how-to-throw-a-custom-fault-on-a-jax-ws-web-service) – kolossus May 18 '16 at 20:57

1 Answers1

0

Yes you are almost right. In our SOAP service what we do is, we create a ServiceError class with a message field and an error code field also we write some constructor in that class.

We catch RunTime error as like follow:

try {

} catch(Throwable t) {
    return new ServiceError(109L,"RunTime Error:"+t.getMessage());
}

You can go through my approach.