Getting http 500 response body with flex - apache-flex

I am using a HttpService object in flex to communicate with the server.
I am using java in the server (tomcat), and once an exception occurs the fault event listener in the flex is called.
I am passing data on the exception in the response body in a xml form.
The thing is the flex fault event does not read the data from the response.
How can i read the response body?

In my experience, you can't. Flex turns any 400-599 response codes into a generic IOError and only gives the status code. My understanding is that this is a browser-plugin limitation, but I'm not sure of the extent/reason.
The way we've gotten around it is that all 400-599's get wrapped as 200-OK with a response showing the details of the error. I've heard many argue that this means Flex/Flash can never truly be a RESTful client.

Related

How to resolve Connection Reset issue in Google calendar API

I am using java and google calendar API to insert/update/delete events from my google calendar. It is working fine.. At times it throws Connection Reset error when writing or updating the event via API.
Is there any possibility to resolve this issue.?
Thanks in advance..
If this is a java code, maybe the SO Posts below can help you determine what's wrong and where did you messed up in your code. Since I am not sure what code you are using, I'll give you an example where this error always occur.
SO post 1
"Exception in thread "main" java.net.SocketException: Connection
reset" error occurs when the opponent is forcibly terminated without
calling close().
Maybe there is something in your code that forced the opponent to be terminated without calling the close() function.
If that's the case, you can add this two line in both
Client
skt.close();
and ServerSock
ss.close();
Note: java.io.Closeable implementing object must call close ().
SO post 2
javadoc for SocketException states that
Thrown to indicate that there is an error in the underlying protocol
such as a TCP error
The connection in the server end maybe closed and caused the issue when sending the issue at their end.
To aid debugging you could look at using a tool such as Wireshark to
view the actual network packets. Also, is there an alternative client
to your Java code that you could use to test the web service? If this
was successful it could indicate a bug in the Java code.
As you are using Commons HTTP Client have a look at the Common HTTP
Client Logging Guide. This will tell you how to log the request at the
HTTP level.
Hope 1 of these two answers will help you.

Do you do client-side logging?

How do you capture errors that happen on client side when building RIA apps using Flex and Silverlight? What are the common practices? I have seen some asynch js calls to a web service implemented but would like to know how the community is dealing with it.
First, I use client side logging all of the times.
the way I handle it depends on the entire application.
if I use an AMF gateway then there's a call for an application error, with every error that occurs the server is notified, in the server side a bug is open in BugZilla (this is what we use, you can use any other hook you want).
If I use a web-service based application then there's a web-service call for a client error.
one would say you shouldn't sample the server with every error, I disagree with this comment because an error in the client side is rare, it goes thorough QA before being released to the client so I want to know immediately on every error the client is experiencing.
In Silverlight I like to use a WebClient to log back to a web service somewhere -- you can do this directly in the Silverlight application without calling out to JavaScript.
To catch exceptions that are fired when your code isn't on the stack, you can use the Application.UnhandledException event.
I've used the same approach as Avi Tzurel - you need to know on the server side when an error appeared in the Flex client. If you want to collect more data (all the log messages, warnings) I would use an internal buffer and I will flush it asynchronously.
Anyway, you need to take into consideration if your customers are ok with this approach..maybe you need their agreement before sending the error message to the server.
I basically percolate all errors to the top, and capture them in the unhandled exception. I display a friendly message to the user. However, throughout my application I implement an ILogger interface. This interface can be initialized with various levels and handles any messaging. You can set it up so the user can add an init param to determine whether or not to transmit the errors to a service, and I typically have the logger write the messages with Debug.WriteLine if the debugger is attached to make it very easy to trace issues in debug mode.
In Silverlight you may want to consider the Logging and Exception Handling Application Blocks from the Silverlight Integration Pack for Enterprise Library.

ASP.NET, asynchronous call to another page, return response immediately

The problem is as follows:
An external server sends incoming SMS messages converted to HTTP requests into my sometimes very time-consuming .aspx page. If no response is returned to the external server in 20 seconds, this is considered as an timeout and the same message is sent to my aspx page again (and maybe again....)
The optimal solution for me would be that the aspx page reads the incoming message (as an HTTP request to the aspx page), starts the processing of the message in another thread, and immediately renders response back to the external server. The external server has no interest in other stuff than the HTTP status (normally 200). When the processing of the message is completed this results in an entry into the log file of the application.
The processing of the message is done by making another web request to an aspx page, and I have tried to use the BeginGetResponse method for the web request, and have created a handler for handling of the completed web request to the processing page. The problem is that the handler seems to not be called, most likely because the aspx page's lifecycle is ended before the asynchrounous web request is completed.
Has anyone any good solution for this problem? I have also looked at the async page model, but this also seems to not be a solution for me because the response should be returned to the external server before the processing of the message is completed.
Regards, Eivind
I'd be very wary of using threads in ASP.Net in this manner. Using them to take advantage of multiple cores is one thing. Using them to set up some kind of concurrent response technique seems like a recipe for disaster. Especially when there is a far more elegant solution.
Your ASP.Net application should merely take the message and toss it in a database and send the success reply. It's job is done. The job of delivering the message should be handled by some kind of service or daemon. Windows Services are kind of a pain to build and maintain so perhaps just a scheduled task that runs every 30 seconds or so checking for queued messages in the DB would suit your purposes just fine.
I've seen a lot of people try to use threads in ASP.Net when they really should just be creating a background service. The results are never as reliable as you would hope.
Async page model is definitely not the solution. Have you tried using the unload event to do EndRequest? I really don't know if that would work but it is worth a try. The most robust way is to use Windows Service to run the async request.

Flex httpservice faults

I've been given a Flex application which made use of a RESTFUL service.
I've managed to create a SQLite DB which stored data from the service and now I would like the application to be able to run offline and make use of the data existing in it's local DB. This works fine the only problem is that the httpService object throws a fault when it cannot connect.
If I don't provide a method to handle the fault event then it is displayed in an error window.
If I provide a blank method to handle the fault then it is still displayed in an error window.
How can I get it to stop displaying this error Window?
Regards,
Craig
Check for a network connection before making the httpservice request.
Flex 3 - Adobe Flex 3 Help - Network Connectivity
That way, when an exception occurs it's really an unexpected behavior instead of something that could be regular program usage.
Never Mind... Problem was that something else was generating the same fault...

Flex 3: ConcurrencyError using HTTPService

I'm getting occasional ConcurrencyError faults when using HTTPService in Flex 3. I have four HTTPService objects, all configured with concurrency=single. I'm not sure though how to continue to diagnose, as I don't see in the FaultEvent what service object caused the issue, and I can't easily reproduce it on-demand.
One feature of my app is that I am also using a URLRequest to load a sound shortly after receiving a result from one of the HTTPService calls. Could this be related to the concurrency error?
The fault looks like this:
[FaultEvent fault=[RPC Fault faultString="Attempt to invoke while another call is pending. Either change concurrency options or avoid multiple calls." faultCode="ConcurrencyError" faultDetail="null"] messageId=null type="fault" bubbles=false cancelable=true eventPhase=2]
Huh. I'm going to call it a bug in Flex 3.2 because upgrading to 3.4 got rid of it.

Resources