# File soap/wsdlDriver.rb, line 266
def initialize(host, wsdl, port, logdev)
@host = host
@wsdl = wsdl
@port = port
@logdev = logdev
@soapaction = nil
@options = setup_options
@default_encodingstyle = nil
@allow_unqualified_element = nil
@generate_explicit_type = false
@mapping_registry = nil # for rpc unmarshal
@wsdl_mapping_registry = nil # for rpc marshal
@wiredump_file_base = nil
@mandatorycharset = nil
@wsdl_elements = @wsdl.collect_elements
@wsdl_types = @wsdl.collect_complextypes + @wsdl.collect_simpletypes
@rpc_decode_typemap = @wsdl_types +
@wsdl.soap_rpc_complextypes(port.find_binding)
@wsdl_mapping_registry = Mapping::WSDLEncodedRegistry.new(
@rpc_decode_typemap)
@doc_mapper = Mapping::WSDLLiteralRegistry.new(
@wsdl_types, @wsdl_elements)
endpoint_url = @port.soap_address.location
# Convert a map which key is QName, to a Hash which key is String.
@operation = {}
@port.inputoperation_map.each do |op_name, op_info|
orgname = op_name.name
name = XSD::CodeGen::GenSupport.safemethodname(orgname)
@operation[name] = @operation[orgname] = op_info
add_method_interface(op_info)
end
@proxy = ::SOAP::RPC::Proxy.new(endpoint_url, @soapaction, @options)
end
req_header: [[element, mustunderstand, encodingstyle(QName/String)], …] req_body: SOAPBasetype/SOAPCompoundtype
# File soap/wsdlDriver.rb, line 361
def document_send(name, header_obj, body_obj)
set_wiredump_file_base(name)
unless op_info = @operation[name]
raise RuntimeError, "method: #{name} not defined"
end
req_header = header_obj ? header_from_obj(header_obj, op_info) : nil
req_body = body_from_obj(body_obj, op_info)
opt = create_options({
:soapaction => op_info.soapaction || @soapaction,
:decode_typemap => @wsdl_types})
env = @proxy.invoke(req_header, req_body, opt)
raise EmptyResponseError unless env
if env.body.fault
raise ::SOAP::FaultError.new(env.body.fault)
end
res_body_obj = env.body.response ?
Mapping.soap2obj(env.body.response, @mapping_registry) : nil
return env.header, res_body_obj
end
# File soap/wsdlDriver.rb, line 304
def endpoint_url
@proxy.endpoint_url
end
# File soap/wsdlDriver.rb, line 308
def endpoint_url=(endpoint_url)
@proxy.endpoint_url = endpoint_url
end
# File soap/wsdlDriver.rb, line 312
def headerhandler
@proxy.headerhandler
end
# File soap/wsdlDriver.rb, line 300
def inspect
"#<#{self.class}:#{@proxy.inspect}>"
end
# File soap/wsdlDriver.rb, line 324
def reset_stream
@proxy.reset_stream
end
# File soap/wsdlDriver.rb, line 328
def rpc_call(name, *values)
set_wiredump_file_base(name)
unless op_info = @operation[name]
raise RuntimeError, "method: #{name} not defined"
end
req_header = create_request_header
req_body = create_request_body(op_info, *values)
reqopt = create_options({
:soapaction => op_info.soapaction || @soapaction})
resopt = create_options({
:decode_typemap => @rpc_decode_typemap})
env = @proxy.route(req_header, req_body, reqopt, resopt)
raise EmptyResponseError unless env
receive_headers(env.header)
begin
@proxy.check_fault(env.body)
rescue ::SOAP::FaultError => e
Mapping.fault2exception(e)
end
ret = env.body.response ?
Mapping.soap2obj(env.body.response, @mapping_registry) : nil
if env.body.outparams
outparams = env.body.outparams.collect { |outparam|
Mapping.soap2obj(outparam)
}
return [ret].concat(outparams)
else
return ret
end
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.