Creating SOAP web services is pretty tedious sepcially for beginners. So, a wise question to ask will be if really a web service is required to retrieve data over internet or a very simple thing like a servlet will do that job?
So some one will need a web service to consume in a Flex app when the business logic has to made available to the third parties too. Other scenarios are like a web service already exists for the functionality.
However, if the data has to consumed for some small apps and not required to be made available to third parties then a simple servlet can do a job which can return the desired XML output in the respone.
Just as an example you can write something like:
public class MyServlet extends HttpServlet {
public MyServlet () {
}
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
try{
resp.setContentType("text/xml; charset=UTF-8");
PrintWriter out = resp.getWriter();
out.println("");
out.print("30 ");
out.println("");
out.close();
}catch(Exception e){
System.out.println("DataException in startFetching ::" + e.getMessage());
e.printStackTrace();;
}
return;
}
}
And in your Flex App you would specifying the url that you will be use to deploy the servlet.
No comments:
Post a Comment