Create custom exceptions in Axis2

血红的双手。 提交于 2019-12-02 22:48:49

问题


I'm using Axis2 1.5.2 and Eclipse. I'm using Eclipse to generate the WSDL and client code from generated WSDL.

I created a custom exception that my service can throw. Everything looks ok when creating the webservice. The webservice starts successfully and I can view the generated WSDL by pointing my web browser. But when I tell Eclipse to generate the Client code using the generated WSDL I get this error from 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)

My custom exception is "InsertUserException":

public class InsertUserException extends Exception{
  private String errorCode;

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

}

My service action that clients can call is "insertUser":

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

Any help is appreciated.


回答1:


Axis2 doesn't know how to send Exceptions over the wire unless they are AxisFaults.

Here's a link to an article on how to use AxisFault with custom exception information.

http://wso2.org/library/171



来源:https://stackoverflow.com/questions/3954632/create-custom-exceptions-in-axis2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!