问题是关于JAX-WS中的异常继承。
@WebService(portName = "TestPort", serviceName = "Test", targetNamespace = "urn:Test", endpointInterface = "test.TestPort")
public class TestService extends TestPort {
@Override
public String test() throws TestException {
throw new MyException();
}
}
@XmlSeeAlso({MyException.class})
@WebFault
public class TestException extends Exception {
public ServiceException() {
super();
}
}
@WebFault
public class MyException extends TestException {
public MyException() {
super();
}
}
我希望MyException被序列化并在WSDL中可见但是我仍然会获得暴露类和包名称的非描述异常的默认错误消息。我试图使用XmlSeeAlso来实现这一目标。但只有'抛出' MyException的声明似乎有效。