开发者

Create custom exceptions in Axis2

开发者 https://www.devze.com 2023-01-20 17:09 出处:网络
I\'m using Axis2 1.5.2 and Eclipse. I\'m using Eclipse to generate the WSDL and client code from generated WSDL.

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 Ec开发者_运维技巧lipse 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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消