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?
Don't ever let your computer know you're in a hurry! :nono:
Balaji Loganathan
author and deputy
Bartender
Joined: Jul 13, 2001
Posts: 3150
posted
0
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.
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
Joined: Jan 29, 2003
Posts: 45
posted
0
If I change RemoteException for Exception when I implement my exception class It works, why?
Balaji Loganathan
author and deputy
Bartender
Joined: Jul 13, 2001
Posts: 3150
posted
0
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
Joined: Jan 29, 2003
Posts: 45
posted
0
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!