views:

80

answers:

1

Hi!

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

+1  A: 

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

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

Michael Sharek