Modifying outgoing HTTP Header/Body (Solution)

1 view
Skip to first unread message

Christoph_Petschnig

unread,
Sep 10, 2008, 5:40:47 AM9/10/08
to soap4r
I thought this could be helpful for some folks looking for help here.
It shows how to modify an outgoing request/response, the header as
well as the body:

# Client request (outbound) #


class ClientOutboundFilter < ::SOAP::Filter::StreamHandler
def on_http_outbound(req)
# working with the final http request
req.body.set_content(req.body.content.gsub(/foo/, 'bar'))
end
end


obj = My_SOAP_RPC_Driver.new('http://example.com/my_url')

# add custom filter
obj.streamhandler.filterchain.add(ClientOutboundFilter.new)

request = MyRequest.new('some content')

response = obj.my_method(request)




# Server response (outbound, in Rails) #


class MySOAPController < ApplicationController

after_filter :modify_response

def modify_response
# working with the final http request
response.body.gsub!(/foo/, 'bar')
end

end

carl....@gmail.com

unread,
Sep 11, 2008, 3:51:02 AM9/11/08
to soap4r
Hi Christoph,

Which bit of your example specifically allows the request header to be
modified?

Regards,

Carl
Reply all
Reply to author
Forward
0 new messages