• 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

Exception handling!

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm learning web services the hard way (big project Vs no time) and I'm drowning to find nfo on internet about handling exceptions in a web-service.
What I've figured out is that exceptions thrown by a web-service are wrapped up by a remote exception (correct me please if I'm wrong) somewhere in a handler and send back as a fault code in a soap message.
Do I have to write a handler to use my personal fault codes.
can somebody post an example please?
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you Apache Axis ?
if so there is example on how to handle such fault exception,shown here, is this what u r looking for ?
To learn quickly, try to run all the examples in apache axis package, then u will get an overall idea what u can-cant do with webservices in general.
 
carlos sanchez
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm trying to understand the examples, and I've generated 2 dummy classes:
***************************************************************
package faults.impl;
public class Dummy
{
public String sayHello(String hello) throws DummyFault
{
if (hello.equals("hello!")) return "hi there!";
else
{
DummyFault fault = new DummyFault();
fault.setInfo("bad maners!");
throw fault;
}
}
}
***********************************************************************
package faults.impl;
import java.rmi.RemoteException;
public class DummyFault extends RemoteException implements java.io.Serializable
{
private java.lang.String info;
public DummyFault() {
}
public DummyFault(
java.lang.String info) {
this.info = info;
}
public java.lang.String getInfo() {
return info;
}
public void setInfo(java.lang.String info) {
this.info = info;
}
}
********************************************************************
As you can see it's the same as the example, but when trying to buid the wsdl (C:\eclipse2.1\eclipse\workspace\Compile>java org.apache.axis.wsdl.Java2WSDL -o dummy.wsdl -l"http://localhost:8080/axis/services/Dummy" -n"urn ummy" -p"urn ummy" "faults" faults.impl.Dummy) I get an :
- The class java.lang.Throwable is defined in a java or javax package and cannot be converted into an xml schema type. An xml schema anyType will be used to define this class in the wsdl file.

Do I have to buid manually my wsdl & wsdd files? (Supose superduper developers with a lot of time do it the hard way!)
 
carlos sanchez
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I change RemoteException for Exception when I implement my exception class It works, why?
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by carlos i sanchez:
As you can see it's the same as the example, but when trying to buid the wsdl (C:\eclipse2.1\eclipse\workspace\Compile>java org.apache.axis.wsdl.Java2WSDL -o dummy.wsdl -l"http://localhost:8080/axis/services/Dummy" -n"urn ummy" -p"urn ummy" "faults" faults.impl.Dummy) I get an :


Don't know why, but did you tried to deploy the service using Adminclient-WSDD file and see the output WSDL using in Axis administration page and error message in servlet log??
 
carlos sanchez
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup! I've followed on and used WSDL2Java, I had to correct some errors on the generated Exception Class (an object casted to a throwable), but axis crashes when I try to load it!
Thanks anyway!
 
reply
    Bookmark Topic Watch Topic
  • New Topic