I want my WebService to throw Custom Defined Exception 'AuthorizationFailedException' like
ManageUserResponse ManageUser(@WebParam(name = "ManageUser") ManageUser body) throws AuthorizationFailedException;
the issue is i am using xsd Schema and i am not able to generate 'AuthorizationFailedException' class that extends java.lang.Exception.
how can i define type of any xsd elemet to Java.lang.Exception.
I need smething like
<xsd:element name="AuthorizationFailedException" type="java.lang.Exception"></xsd:element>
If you want to map an exception to a fault bean, then take a look at the @WebFault annotation.
Otherwise, I am not entirely clear if you do Java first or WSDL first development?
Perhaps it is even meet-in-the-middle?
Have you tried using XJC, the JAXB tool, to generate Java bean classes from the XML schema?
Joined: Dec 29, 2003
thanks for reply,
@WebFault annotation is part of WSDL rigth?
The issue is i am usign xFire Codehaus to generate my WSDL and schema classes. and i don't know what settign are required so generated WSDL contain @WebFault annotation.
I need help in generating WSDL with @WebFault.
Well i don't have any separate class there for exception, what i all did is that i created a complex type with name 'AuthorizationFailedException' and when xFire Generator generated its JAXB class i added 'extends Exception' to that. I know that it must be wrong but i am doing it first time so i have no such idea how we can use User Defined Exception. After that i added thorws AuthorizationFailedException in my WS methods. when i made request it showed error that illegalAnnotationExcetion and that no default Constructor found.
So I want to know that how can i make xsd that will generate a valid wsdl:fault in WSDL on generation. i will be grateful if someone provide us sample code of xsd schema that generates a valid wsdl:fault element. Or explain how we can use user defined exception in WS.