Web services 使用CXF生成WebService会生成异常\u异常类

Web services 使用CXF生成WebService会生成异常\u异常类,web-services,wsdl,cxf,wsdl2java,Web Services,Wsdl,Cxf,Wsdl2java,我们有一个Web服务实现,它抛出一个定制的SecurityException public class SecurityException extends Exception { 然后使用maven插件java2ws将服务转换为wsdl。生成的.wsdl文件包含 <xs:element name="SecurityException" type="tns:SecurityException"/> <xs:complexType name="SecurityExcept

我们有一个Web服务实现,它抛出一个定制的
SecurityException

public class SecurityException extends Exception {
然后使用maven插件
java2ws
将服务转换为wsdl。生成的.wsdl文件包含

  <xs:element name="SecurityException" type="tns:SecurityException"/>
  <xs:complexType name="SecurityException">
  ...
  <wsdl:message name="SecurityException">
    <wsdl:part name="SecurityException" element="tns:SecurityException">
    </wsdl:part>
  </wsdl:message>
安全异常\u异常文件:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SecurityException")
public class SecurityException {


}
@WebFault(name = "SecurityException", targetNamespace = "http://service...../")
public class SecurityException_Exception extends Exception {


private ....SecurityException securityException;

public SecurityException_Exception() {
    super();
}

public SecurityException_Exception(String message) {
    super(message);
}

public SecurityException_Exception(String message, Throwable cause) {
    super(message, cause);
}

public SecurityException_Exception(String message, ....SecurityException securityException) {
    super(message);
    this.securityException = securityException;
}

public SecurityException_Exception(String message, ....SecurityException securityException, Throwable cause) {
    super(message, cause);
    this.securityException = securityException;
}

public ....SecurityException getFaultInfo() {
    return this.securityException;
}
}
我怎样才能避免不必要的课程?它为什么会产生?为什么它不能重新创建旧类

SecurityException extends Exception

(我们使用的是cxf版本2.5,所以解决了这个问题。显然,您无法避免helper类,因为在web服务中使用异常时必须对其进行包装,因为它们是不可序列化的。

我使用的是JAXB内置maven(jaxws maven插件/wsimport目标),但我也遇到了同样的问题。(它生成了BusinessException和BusinessException\u Exception)

我的修复方法是将异常放在另一个命名空间中。因此,现在我有两个BusinessException文件,生成于两个不同的文件夹中,其中一个是异常,将另一个作为其参数。编译正常,无异常