开发者

How to handle HTTP Request at server

We have an Rails site which also connects to our suppliers to get XML info from them. For that I use Net::HTTP to make requests from our end and think of i开发者_C百科t as 'black box' stuff.

Now one of our suppliers wants to send XML data to us at random intervals. i.e. They are the ones making the HTTP Request rather than just responding to one of our HTTP Requests.

Now that the table has been turned on us, do I need to set up something 'special' on our server to listen out for their requests?

Logic says that their HTTP Request is no different to any that a browser makes, in which case all I would need to do is tell them which 'Controller/Method' to point it at.

My question is, is it really that simple or do I have to set up other stuff?


At its most basic, its that simple. A controller method that handles an HTTP POST or PUT request will do it. Complexity may show up in other areas though: You will need to decide if you want to do something to ensure that the data is only coming from where you expect, and what to do if their data is lacking key fields (which you would normally catch with validation and send back to the user).


I think its not a big deal. You can have your URL (controller/action) which serve the request by taking xml from the request and return some flag(text). You have to provide that URL to the suppliers and ask him to post xml on the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜