【问题标题】:Create custom exceptions in Axis2在 Axis2 中创建自定义异常
【发布时间】:2011-04-26 15:50:31
【问题描述】:

我正在使用 Axis2 1.5.2 和 Eclipse。我正在使用 Eclipse 从生成的 WSDL 生成 WSDL 和客户端代码。

我创建了一个我的服务可以抛出的自定义异常。创建 Web 服务时一切正常。 Web 服务成功启动,我可以通过指向我的 Web 浏览器来查看生成的 WSDL。 但是,当我告诉 Eclipse 使用生成的 WSDL 生成客户端代码时,我从 Eclipse 收到此错误:

Error in generating Java from WSDL:  java.io.IOException: ERROR: Missing <soap:fault> element inFault "InsertUserException" in operation "InsertUserException", in binding insertUser
    java.io.IOException: ERROR: Missing <soap:fault> element inFault "InsertUserException" in operation "InsertUserException", in binding insertUser
    at org.apache.axis.wsdl.symbolTable.SymbolTable.faultsFromSOAPFault(SymbolTable.java:2858)

我的自定义异常是“InsertUserException”:

public class InsertUserException extends Exception{
  private String errorCode;

  public InsertUserException(String errorCode){.....}
  public String getErrorCode(){...}
  public void setErrorCode(String errorCode){...}

}

客户可以调用的我的服务操作是“insertUser”:

public void insertUser() throws  InsertUserException{
.....
}

感谢任何帮助。

【问题讨论】:

    标签: java web-services axis2


    【解决方案1】:

    Axis2 不知道如何通过网络发送异常,除非它们是 AxisFaults。

    这是一篇关于如何使用带有自定义异常信息的 AxisFault 的文章的链接。

    http://wso2.org/library/171

    【讨论】:

    • 我认为 Axis2 会以某种方式进行转换,但这个解决方案对我有用。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    • 2011-11-18
    • 2023-03-04
    相关资源
    最近更新 更多