-
Notifications
You must be signed in to change notification settings - Fork 1
Description
I don't believe that the fixes for #1 actually fixed the issue. If I could reopen that issue I would but alas I cannot. I am still having the same problem after updating the gem.
Based on the HttpClient documentation it would appear that client.post(url, body, headers) is exactly equivalent to client.post(url, :body => body, :header => headers). So the patch submitted should not have changed anything.
The problem is not the :body => body in #post since that is just stylistic, the problem is actually in the fact that the webservice is wrapping the argument in :body => and then callback-handler is not expecting that.
Again see opener-webservice (2.0.0):
callback_handler.post(url, :body => output, :header => headers)This results in params being the hash :body => output, :header => headers in the following:
def process(url, params = {})
body = JSON.dump(params)
http.post(url, body, HEADERS)
endThus the JSON that gets posted looks like {"body":{"input":"...},"header".
You may not be running into this issue with the later version of webservice (I have not been able to use that with the other gems).
It is not clear to me if the #process method should be handling the spliting of :body and :header from params. I see 3 solutions:
- If it is meant to receive
paramsas a hash like:body => something, :header => something(as it is from webservice 2.0.0) then the following should work:
def process(url, params = {})
body_data = params[:body] || {}
header_data = params[:header] || {}
body = JSON.dump(body_data)
http.post(url, body, HEADERS.merge(header_data))
end- If 1 should be supported and the process method must remain compatible with a hash input that is not wrapped in
:body =>then the following should work:
def process(url, params = {})
body_data = params[:body] || params
header_data = params[:header] || {}
body = JSON.dump(body_data)
http.post(url, body, HEADERS.merge(header_data))
end- If the process method is not meant to be receiving
paramsthat looks like{:body => something, :header => something_else}then the webservice needs to change. Probably to:
callback_handler.post(url, output)