I am pretty excited about the opportunity to present at the upcoming 360|Flex conference in San Jose from August 18 to 20. My coworker and I will give a talk about our experiences and what we had learned from developing an internal SOA application at Yahoo!. This application uses Flex and a host of Java technologies on the server side. Come and check us out in August in San Jose.
Servlet Filter Came To The Rescue
December 29, 2007In my previous post I outlined a couple of limitations that Flex HTTPService class has in dealing with Restful style web services. After giving it some thought, I came up with a solution that will allow me to continue to use Flex with Restful style web services without changes to the backend. The core of the solution is the idea of intercepting the incoming request on the server side using Servlet filter and use the Decorator pattern to adapt the needs of the service Restful web services. The solution consists of the following parts:
- Servlet filter to intercept incoming Restful style web service requests
- Develop a custom HttpServletRequest wrapper class that converts information like method name or header from the request parameters into right format that the server side web service handlers require.
- Develop a custom HttpServletResponse wrapper to convert all status code to 200 so flex will be able to get to response body
The above solution is very specific to my application and the willingness to bend some rules in making Restful web services calls from the Flex front end. Basically each web service request will append a request parameter with an agreed upon name between client and the server. Only when this special request parameter is present, the the Servlet filter will trigger the usage of request wrapper and response wrapper. The other issue with status code is since my Restful web service APIs return an error message in an XML structure in the response body, which allows the Flex client to find out what’s wrong.
With this solution, I am able to continue to Flex to develop my application UI.
Happy flexing everyone.
Flex Is Not Friendly To REST
December 26, 2007I am a big fan of Flex until now and the reason is the HTTPService that Flex provides doesn’t play well with REST. You see I am developing an application that uses Jersey/Spring/JPA on the server side and my plan was to use Flex to talk to the server side using Restful style web services. The problem is HTTPService class has several major limitations:
- Only GET and POST methods are supported out of the box (unless you use FDS and set useProxy attribute to true)
- Not able to set request headers and there is no access to response headers. Therefore I am not able to access the response body in the case of an error.
- It HTTPService gets a status code anything other 200, it consider an error. (event 201, ouch!!). The FaultEvent doesn’t provide information about the status code any response body. The Flex client will have no idea what went wrong.
I have spent quite a bit of time reading blogs after blogs about these issues and I don’t see an clean solution out there yet. Here is a list of blogs that talk about the very same issues that I listed above
I am doing research for a couple more days and if I can’t find anything clean solution to overcome these limitations, I am afraid Flex will not be used in this project. This is really disappointing!!
Drop me a note if you know any tips or tricks to overcome the limitations of HTTPService.
Posted by fantastic
Posted by fantastic
Posted by fantastic