cancel
Showing results for 
Search instead for 
Did you mean: 

Exception handling in Web Services

former_member190457
Contributor
0 Kudos

Hi all,

I am exposing ejb2-based webservices and am unable to find a way to throw checked Exceptions.

Could anyone provide resources about how to leverage SOAP/WSDL features of exception handling (i.e. wsdl:fault tag)?

Thanks, regards

Vincenzo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Vincenzo,

It should be possible if you have defined an own Exception in your business method of the EJB.

The Exception will get published as Fault Message in your WebService /generated WSDL.

With best regards

Sebastian

former_member190457
Contributor
0 Kudos

Hi, thanks for replying

actually on saphelp I found that supported Exceptions are:

java.lang.Exception -> no fault generated

java.rmi.RemoteException -> deploy refused with explicit error (RemoteException not allowed in ejb business method signature)

java.lang.Throwable -> doesn't seem very appropriate to use such a root class

Any suggestion?

Thanks, regards

Vincenzo

Former Member
0 Kudos

Hello Vincenzo,

It should be definitly possible for a java.lang.Exception.

Did you try delete your Virtual Interface File and generate it new?

(I assume you work on EJB' s on SAP Java Web AS 6.40 or 7.0)

With best regards

Sebastian

former_member190457
Contributor
0 Kudos

Hi,

where should I add the "throws exception"?

I added it both in the implementation and in the local/remote interfaces

Is that enough?

thanks

Vincenzo

former_member190457
Contributor
0 Kudos

Hi I managed to get the Exception in the wsdl, thanks so much

now:

1. will the proxy throw an Exception in its signature?

2. can I use my own Exception classes?

Thanks, regards

Former Member
0 Kudos

Hi,

Yes it must be present in the interface (a remote interface should be enough) and the implementation.

Just delete alle Web Service Metafiles (Virtual interface, etc) and try to create the Web Service newly.

It should have then an the Exception in the VI Types section which leads to a defined Fault Message in

the WSDL.

With best regards

Sebastian

former_member190457
Contributor
0 Kudos

Hi, thanks now I can see the exception as fault

I have tried using my own exception class, but in the Vi it is always mapped as java.lang.Exception

am I allowed to use my own exception class?

Thanks, regards

Former Member
0 Kudos

Hi,

I think that s just an update problem of your meta files,

try to delete operation in your vi ("remove") and add it again

then you ll see your own exception class in the types section.

best regards

Sebastian

Former Member
0 Kudos

Sebastian,

I'm trying something similar, can we customise the faultcode and faultString?

Rajiv.

former_member190457
Contributor
0 Kudos

Hi, in the end I managed to do it,

Yes you can customize almost everything, but I didn't manage to get the classic message from java.lang.Exception,

so I defined my string instance variable in the extending class and used it instead.

Thanks

regards

Vincenzo

Former Member
0 Kudos

Vincenzo,

My problem is, I'm using a SOAPhandler along with my EJB webservice. Without the handler the faultstring looks good. but when I have the handler on the faultstring has -'javax.ejb.EJBException: Exception raised from invocation...... '. As the handler is getting the ejb exception.

Have you used Handlers much?

Thanks,

Rajiv.

Answers (0)