summaryrefslogtreecommitdiff
path: root/lib/soap/rpc/proxy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/soap/rpc/proxy.rb')
-rw-r--r--lib/soap/rpc/proxy.rb52
1 files changed, 42 insertions, 10 deletions
diff --git a/lib/soap/rpc/proxy.rb b/lib/soap/rpc/proxy.rb
index 5825a27138..7d9dbe519e 100644
--- a/lib/soap/rpc/proxy.rb
+++ b/lib/soap/rpc/proxy.rb
@@ -12,6 +12,7 @@ require 'soap/mapping'
require 'soap/rpc/rpc'
require 'soap/rpc/element'
require 'soap/streamHandler'
+require 'soap/mimemessage'
module SOAP
@@ -79,7 +80,6 @@ public
raise SOAP::RPC::MethodDefinitionError.new(
"Method: #{ name } not defined.")
end
-
Request.new(method, values)
end
@@ -91,21 +91,30 @@ public
req_body = SOAPBody.new(req_body)
end
opt = create_options
- send_string = Processor.marshal(req_header, req_body, opt)
- data = @streamhandler.send(send_string, soapaction)
- if data.receive_string.empty?
+ opt[:external_content] = nil
+ req_env = SOAPEnvelope.new(req_header, req_body)
+ send_string = Processor.marshal(req_env, opt)
+ conn_data = StreamHandler::ConnectionData.new(send_string)
+ if ext = opt[:external_content]
+ mime = MIMEMessage.new
+ ext.each do |k, v|
+ mime.add_attachment(v.data)
+ end
+ mime.add_part(conn_data.send_string + "\r\n")
+ mime.close
+ conn_data.send_string = mime.content_str
+ conn_data.send_contenttype = mime.headers['content-type'].str
+ end
+ conn_data = @streamhandler.send(conn_data, soapaction)
+ if conn_data.receive_string.empty?
return nil, nil
end
- opt = create_options
- opt[:charset] = @mandatorycharset ||
- StreamHandler.parse_media_type(data.receive_contenttype)
- res_header, res_body = Processor.unmarshal(data.receive_string, opt)
- return res_header, res_body
+ unmarshal(conn_data, opt)
end
def call(headers, name, *values)
req = create_request(name, *values)
- return invoke(headers, req.method, req.method.soapaction || @soapaction)
+ invoke(headers, req.method, req.method.soapaction || @soapaction)
end
def check_fault(body)
@@ -116,6 +125,29 @@ public
private
+ def unmarshal(conn_data, opt)
+ contenttype = conn_data.receive_contenttype
+ if /#{MIMEMessage::MultipartContentType}/i =~ contenttype
+ opt[:external_content] = {}
+ mime = MIMEMessage.parse("Content-Type: " + contenttype,
+ conn_data.receive_string)
+ mime.parts.each do |part|
+ value = Attachment.new(part.content)
+ value.contentid = part.contentid
+ obj = SOAPAttachment.new(value)
+ opt[:external_content][value.contentid] = obj if value.contentid
+ end
+ opt[:charset] = @mandatorycharset ||
+ StreamHandler.parse_media_type(mime.root.headers['content-type'].str)
+ env = Processor.unmarshal(mime.root.content, opt)
+ else
+ opt[:charset] = @mandatorycharset ||
+ ::SOAP::StreamHandler.parse_media_type(contenttype)
+ env = Processor.unmarshal(conn_data.receive_string, opt)
+ end
+ env
+ end
+
def create_header(headers)
header = SOAPHeader.new()
headers.each do |content, mustunderstand, encodingstyle|