Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Flex - Getting the HTTP error code raised from SAP

former_member199581
Active Participant
0 Kudos
137

Hi all,

is there a way to catch the error code returned by a BSP page?

For example, I have a Flex HTTPService that points to a BSP page somedata.xml, which is populated after retrieving data in onInitialization handler.

In this handler, if something goes wrong, I set up the response error code like this:

try.
 "Data Handler Class
catch zcx_some_exc into lx_some_exc.
  error_string = lx_some_exc->get_text( ).
  response->set_status( code = 500 reason = error_string ).
endtry.

In my faultHandler function in Flex, I need to display error_string in an Alert box:

private function HTTPFaultEventHandler(event:FaultEvent):void{
  Alert.show(event.fault.faultString);
}

But in this way, it always display "HTTP Request error".

Anyone can help me?

Thanks a lot,

R.

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos
85

This is a known issue with flex HTTPService.

what you could do is

set the status to 200 for BSP response

and pass the error message in xml format.

on the flex side, in your result handler, check the xml to see whether its error xml or your normal result xml.

if its error xml, you can provide an alert and then stop processing.

Ref: http://onrails.org/articles/2008/02/20/dealing-with-http-errors-in-a-flex-with-rails-application

Regards

Raja

3 REPLIES 3

athavanraja
Active Contributor
0 Kudos
86

This is a known issue with flex HTTPService.

what you could do is

set the status to 200 for BSP response

and pass the error message in xml format.

on the flex side, in your result handler, check the xml to see whether its error xml or your normal result xml.

if its error xml, you can provide an alert and then stop processing.

Ref: http://onrails.org/articles/2008/02/20/dealing-with-http-errors-in-a-flex-with-rails-application

Regards

Raja

0 Kudos
85

Hi Durairaj,

thanks for the hint.

This is how I'm doing already, I'd not have the time to investigate why it did not work and I have used this workaround.

So, if I've understood well, currently there's no other way to catch http error codes.

I've read about this project: http://code.google.com/p/as3httpclientlib/

Did you ever tried it?

Thanks a lot,

R.

0 Kudos
85

So, if I've understood well, currently there's no other way to catch http error codes.

With HTTPService - yes. but you could use URLLoader class if handling HTTP status code is important

i have seen http://code.google.com/p/as3httpclientlib/ but yet to try it.

Regards

Raja