views:

709

answers:

2
+1  Q: 

JAX-WS Exception

How to assign the fault field of the SOAPFaultException on the server side?

+1  A: 

As far as I can tell, the only way to assign a fault field is through the constructor. So, the easiest way would be to create a new SOAPFaultException with the fault as an argument.

R. Bemrose
A: 

define exception

public class SomeFault extends Exception
{
   public SomeFault(String code)
   {
   }

   public String getA() {...}
   public void setA() {..}

   public String getB() {...}
   public void setB() {..}
}

and then webservice

@WebService
public class MyWS
{
   public MyWS()
   {
   }

   public Response getSomething(String id) throws SomeFault 
   {
      throw new SomeFault(id);
   }
}
Mykola Golubyev