简体   繁体   中英

Axis2 WebService and multiple ExceptionFault elements in WSDL

I am not AXIS2 expert, therefore I am using Eclipse to generate bottom - up webservice. I am publishing 2 methods as webservices. These methods are defined to throw java.lang.Exception in order to produce SOAPFault when calling webservice that ends with exception.

public class sample {

 public String someMethod() throws Exception {
  throw new CustomException("Error: blabla");
 }


 public String someOtherMethod() throws Exception {
  throw new CustomException("Error: blabla");
 }

}

After publishing webservice, everything is working OK. But WSDL generated by AXIS2 seems to be defect. There are 2 ExceptionFault elements (one for each method?), which is problem for some webservice clients.

<xs:element name="ExceptionFault">
   <xs:complexType>
      <xs:sequence>
         <xs:element name="Exception" nillable="true" type="xs:anyType"/>
      </xs:sequence>
   </xs:complexType>
</xs:element>

What is the problem? Is there something wrong with my implementation? I have also tried to declare methods to throw directly CustomException, or to throw Exception, but with no success...

Martin

If you remove the "throws Exception" from the method signatures it won't generate WSDL with an Exception element.

If your CustomException extends RuntimeException (ie it is an unchecked exception) then you will be fine. The RuntimeException will get turned into a SOAPFault properly by Axis.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM