• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom Exception in WebService

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want my WebService to throw Custom Defined Exception 'AuthorizationFailedException' like
@WebMethod
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>

Zaid Ansari
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
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?
Best wishes!
 
Zaid Ansari
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post you Exception class code as most of the times the problem with such case is that either you have field defined private in the exception which is used in the constructor.

We would be able to understand your problem if you paste your Exception defination code here.

Thanks,
Rahul
 
Zaid Ansari
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic