简体   繁体   中英

JAX-WS Exception

如何在服务器端分配字段?

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.

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);
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM