Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to throw java standard checked Exception in web service  RSS feed

 
walter wang
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my web service method. if it declares throws any standard java checked Exception (or any exception from java API , for example java.io.IOException)
then in generated client code by wsimport or wsdl2java, it will generatel IOException_Exception instead of IOException. which is not what I want or client side expected
Any ideas to solve this problem?
I know how to throw custom defined exception by reading this link
http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-and-exceptions-in-java-jaxws-web-services.html

 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure what your query is but if you want to rename IOException_Exception to MyException, then you can use bindings xml while executing wsimport command..
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me it would be more in keeping with SOAP principles to catch any Exception and use it to create a WebServiceException using the constructor that takes a Throwable.

Then you only have to declare that general WebServiceException which any client code should be able to understand.

Bill
 
walter wang
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I think your suggestion is the solution.
There is no why to make generated stub client code using throws java.io.Exception.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!