cancel
Showing results for 
Search instead for 
Did you mean: 

Handling Java Web Service Exception in ABAP

former_member182416
Active Contributor
0 Kudos

Hi

I have created a web service in Java using NWDS.

Which has a businessMethod which throws a Exception based on certain business logic.

I have consumed this Web Service Method using .NET Client.

i am able to catch the Exception and get the Exceltion Message.

But when i try to consume the same web service Method in ABAP,

i am not getting the Exception Message .

The Method call works fine.

What am i missing here ?

regards

Rajendra

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member182416
Active Contributor
0 Kudos

awaiting answer.

Former Member
0 Kudos

Hi,

Try to create exception in Java with standard fault message available. This should create fault message in ABAP while creating proxy.

Regards,

Gourav

former_member182416
Active Contributor
0 Kudos

Hi

I have defined a Custom Exception Class MyException which extends Exception Class.

and in the businessMethod i use this code

throw new MyException("This is a custom exception");

to throw the Exception.

As i wrote earlier,when i test this webservice from dotnet applciation,

i am able to catch the exception and get the exception message.

But not from ABAP.

Can you throw some light on this issue ?

Regards

Rajendra

Edited by: Rajendrakumar Gaikwad on Feb 9, 2010 6:53 AM

Former Member
0 Kudos

Hi,

Preferred approach is first to model service in ESR and assign "Fault Message" to operation and then use this wsdl in NWDS to create service.

Instead of using your own exception method please use SOAPFault exception, please see other standard services available on ABAP side to analyse standard SOAP fault message, you can extend this exception further.

ABAP will create object if it is similar or derived from standar fault message.

Regards,

Gourav

former_member182416
Active Contributor
0 Kudos

Hi

what is ESR got to do with this ?

please let me know SOAPFault exception is available in which package, i will try that.

Regards

Rajendra

Former Member
0 Kudos

Hi,

>what is ESR got to do with this ?

If you model service in ESR and use wsdl generated from ESR to create service in CAF you will get all required methods and operation by default and they will be compatible with SAP approach.

Use "com.sap.caf.rt.exception.CAFServiceException"for all exception related to service. Fault is available as predefined type in CAF see following: http://help.sap.com/saphelp_nwce711/helpdata/en/43/78a5fd869b6fcbe10000000a1553f6/content.htm

Use exception only from above listing which will create proxy object of type "Fault" in ABAP as well.

Please Java Doc for CE for more detail: http://help.sap.com/javadocs/nwce/ce71/caf/index.html

Regards,

Gourav

former_member182416
Active Contributor
0 Kudos

Hi Gourav,

Thanks for the links.

We are running SAP Netweaver EP 7 SP 18 (Java Stack Only) .

and Developing a web service in java which willbe called by ABAP.

We don't have ESR and SAP Netweaver CE.

So how to go about it ?

Regards

Rajendra

Former Member
0 Kudos

Hi,

In such case use NWDS 7.1 (doesn't matter if you don't have CE 7.1 or not). You will get all required java library and then you can build service with CAFexception.

Just make sure all necessary library also deployed along with service.

I assume you have ECC 6.0 on ABAP side?

Another method is just to deploy necessary libaray in NWSD to make it work or do not raise exception but return empty body with message and handle excpetion internally in the service.

Regards,

Gourav

former_member182416
Active Contributor
0 Kudos

not solved

former_member182416
Active Contributor
0 Kudos

Hi,

Upon further investigation and comparison of the custom exception object (generated during consumer proxy creation for a CUSTOM web service) with a standard exception object(generated during consumer proxy creation for a STANDARD web service) I found that the sub-elements of the exception structure errorPart are not available in the custom exception object (and one of these sub-elements is the message text).

Call Stack,ExceptionName and MessageText Elements are missing in the errorPart node of Exception

Node. as seen in the ABAP Exception structure generated.

Queries:

1. Are there any standards which need to be followed when coding exceptions in the Java web service for consumption in ABAP such that all sub-elements of the exception object are also created in ABAP during the proxy creation?

2. Can we get the Java code for a standard web service available in SAP Netweaver? Asking the same as the exception object created for the standard web service RoomABAPWS contains the sub-elements. Getting the Java code of the same will be very helpful in resolving the issue.

Regards

Rajendra