This week's book giveaway is in the Agile/Processes forum.
We're giving away four copies of Building Green Software: A Sustainable Approach to Software Development and Operations and have Anne Currie, Sarah Hsu , Sara Bergman on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Within the infrastruture - How to and Where - to intercept HTTP request and to send HTTP response?

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need help in finding out how to and where (in the infrastructure) to intercept an HTTP request (PUT, GET...), capture its associated data, process it and then create an XML file to send out with an HTTP response, either manually or if there is a way to set up the plumbing to allow this to happen.

Spring 3.x and Hibernate 3.x with annotations are used. It is a Web application. Where should all these happen within the project infrastructure (in Eclipse).

Is there any sample code out there that I can use? This seems to be a very common thing that is done all the time; - (in the confines of Spring+Hibernate, that is)

Can someone please help me?

Many Thanks in advance.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you're asking--are you saying you want to do something other than the normal request flow? If so, why?
 
Mimi Tam
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

This project is for a web service and the purpose of it is to run in a Server as a web application, take in HTTP requests from mobile phones and send out HTTP responses with results from MySQL databases via Hibernate; in XML format back to the mobile device.

I am using @RequestMapping in the controller and different views like Create, Show, List...etc.


For views e.g.


If the normal request flow allows me to receive a HTTP request, examines data that comes with this request, access MySQL via Hibernate to process and retrieve results and finally allows me to compose a XML file and send it back to the requester via a HTTP response, should I put this business logic within the Controller and using the model and view paradigm like below, e.g. the HTTP request is a GET for all the businesses that are established after year 2001. The web service will first need to know about this criteria (i.e. businesses opened after 2001), look up database and instead of displaying the result on a View, it needs to compose an XML file to send out with the HTTP response.

I don't know how and where I can plug this business logic within the normal request flow and let the plumbing does the packet flow stuff. E.g.


Should I create the HTTP Requests as POJOs and use to them as data models to map to the different HTTP Requests (i.e. GET, PUT, POST....) coming in and create Views for the different XML files that need to be composed/filled-in for returning with the HTTP Response? If that is the case, I only need to create Request POJOs and Response Views and let the current request flow plumbing infrastructure do the rest?

I hope my question is made a bit clearer.

Looking forward to your help.

Many Thanks.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still don't see how this is different than what Spring already does: are you asking how to change the response type (HTML vs. XML) based on the client?
 
Mimi Tam
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am quite new in Spring and REST and really needing some sample code.

I knew I need to use HttpMessageConverter to read and write XML using Spring's marshaller and unmarshaller and the MarshallingView uses XML Marshaller to render the response content as XML.

If I have a Response Bean that represents my HTTP Response XML schema, the JAXB2 marshaller will turn this bean into XML.

Although I am expecting XML requests and response, I am not sure if I still need the ContentNegotiatingViewResolver.

And for REST mappings (HTTP to CRUD), do I create POJOs for each HTTP Request and Response (GET,PUT,POST,DELETE...) and Views for each XML relevant contents that I need to receive and sent out?

How do I put all these together in a RESTFUL way? I tried Roo to examine what's generated for me but I think I need more info and SAMPLE CODE to start.

Can you point me to a Sample project that does closest to what I am looking for to use as a project+code template ?

Many Thanks and I really need some help to do this a.s.a.p.

Sincerely....

 
Mimi Tam
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

....I should add that I am looking for the server-side code.
 
Mimi Tam
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I may be more specific in what I hope to get, someone will/may help me...hopefully.

I have general understanding of the RESTful support from Spring 3.0. I have pieces of the components but I need sample code to put this all together.

I am looking for a sample RESTful project that includes the following key words:

Marshaller
UnMarshaller
MarshallingHttpMessageConverter
Marshalling View
@RequestBody
@ResponseBody
XSLTView
CRUD REST mappings
<other regular ones....>

Looking forward to your help.

Many Thanks in advance.

 
reply
    Bookmark Topic Watch Topic
  • New Topic