dqx76962 2013-08-13 07:39
浏览 43
已采纳

处理发布请求

yesterday i started brainstorm for a project of mine and I'm not sure if its the correct approach. On my website I'm having an (kind of an order form) which sends a post to a target URL, which works with a simple curl php script. The target is an external service (where I have no access no rights, nothing). I only know that I will get a POST with further processed data back from the service, which I have to save into my DB.

in steps:

  1. Users fills out the (order) form and posts data to an external url on my website.

  2. data gets externally handled and after finishing that resents a post.

  3. read incoming post data.

  4. save data into DB.

  5. Success page on my website.

My thoughts were to handle the incoming data with a servlet (spring maven project) but I'm not sure if this is a correct approach. Is there a better why to do this. Or is the first step with the php scripts wrong. thx for any help.

  • 写回答

2条回答 默认 最新

  • dps123456789 2013-08-13 07:55
    关注

    A simplest workflow could be 1. Forward the initial (Order form with values) request to a servlet 2. Invoke a post request using java to an external url inside this servlet (Using Apache http client, or libraries such as HTMLUnit) 3. Once you get the incoming response in your servlet, you can update your database.

    If you are using spring, the controller could forward initial request to a business class which will handle this post processing and delegate the database update to respective DAO.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?