Question

Possible Duplicate:
JAX-WS - Map Exceptions to faults

I do not normally use java, but I being forced to write a service wrapper around a 3rd party library that I need. (So I can call it from c#)

I am using NetBeans with GlassFish, and I was wondering how to work with SOAP Faults in there.

  @WebMethod(operationName = "hello")
  public String hello() throws Exception
  {
    return "Hello World!";
  }

How do I change this so that any exceptions thrown inside hello() get turned into Faults? Even a single fault that just contains the exception message will do for now.

I really just have no idea how to deal with faults in this environment... any information will help.

Was it helpful?

Solution

Try this instead:

@WebMethod(operationName = "hello")
public String hello() {
  try {
    return "Hello World";
  } catch(Exception e) {
    // Throw the fault here.
  }
}

Look here for more:

JAX-WS - Map Exceptions to faults

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top