summaryrefslogtreecommitdiff
path: root/lib/soap/wsdlDriver.rb
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-25 07:31:33 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-11-25 07:31:33 +0000
commit6a09e1d9664f86b7deb576fb0dfe57e10503bb85 (patch)
tree49dc2abcb7640c805848e543d4e5d110cbde5ad6 /lib/soap/wsdlDriver.rb
parentec373c3e1c332f814225c3d49ded8217545470e2 (diff)
* lib/soap/**/*.rb, lib/wsdl/**/*.rb, lib/xsd/**/*.rb: changed license; GPL2 -> Ruby's.
* lib/soap/rpc/driver.rb, lib/soap/wsdlDriver.rb, lib/soap/streamHandler.rb: add interface to streamhandler. * lib/soap/marshal.rb: raise error if parse fails. * lib/soap/netHttpClient.rb: add https support. Patched by Oliver M. Bolzer. * lib/soap/netHttpClient.rb: dump HTTP response message body by itself. * lib/soap/rpc/driver.rb, lib/soap/rpc/proxy.rb, lib/soap/wsdlDriver.rb: add driver#mandatorycharset interface to foce using charset for parsing response from buggy server. * lib/soap/encodingstyle/soapHandler.rb: support Apache Axis's half typed multi-ref array. * lib/soap/mapping/factory.rb, lib/soap/mapping/registry.rb: map SOAPStruct which has multi-accessors which name are the same, to an array. * lib/soap/rpc/element.rb: fixed illegal parameter order. * lib/soap/rpc/element.rb: element name of response message could have the name other than 'return'. * lib/wsdl/operation.rb, lib/wsdl/operationBinding.rb, lib/wsdl/soap/classDefCreator.rb, lib/wsdl/soap/methodDefCreator.rb, lib/wsdl/soap/methodDefCreatorSupport.rb: WSDL/1.1 allows plural fault definition in a operation. [ruby-talk:84948] * test/wsdl/multiplefault.wsdl, test/wsdl/test_multiplefault.rb: add test for above fix. * lib/wsdl/soap/complexType.rb: support WSDL array definition with maxOccures="unbound". * lib/xsd/charset.rb: use cp932 under emx. Patched by Siena. / SHINAGAWA, Norihide in [ruby-dev:21972] * lib/xsd/xmlparser/parser.rb: set @charset nil by default. Nil means 'follow encoding declaration in XML'. * sample/soap/digraph.rb, sample/wsdl/amazon/wsdlDriver.rb, sample/wsdl/googleSearch/sampleClient.rb, sample/wsdl/googleSearch/wsdlDriver.rb, test/wsdl/test_emptycomplextype.rb, test/wsdl/marshal/test_wsdlmarshal.rb, test/xsd/test_xmlschemaparser.rb: use File.open(...) { |f| f.read } instead of File.open(...).read. [ruby-dev:21964] * test/wsdl/emptycomplextype.wsdl, test/wsdl/test_emptycomplextype.rb: simplify the test case. * test/wsdl/axisArray/*: add tests for axis's array encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/soap/wsdlDriver.rb')
-rw-r--r--lib/soap/wsdlDriver.rb87
1 files changed, 41 insertions, 46 deletions
diff --git a/lib/soap/wsdlDriver.rb b/lib/soap/wsdlDriver.rb
index 6ecc4b4f6e..d629aa12ce 100644
--- a/lib/soap/wsdlDriver.rb
+++ b/lib/soap/wsdlDriver.rb
@@ -1,20 +1,9 @@
-=begin
-SOAP4R - SOAP WSDL driver
-Copyright (C) 2002, 2003 NAKAMURA, Hiroshi.
+# SOAP4R - SOAP WSDL driver
+# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-PRATICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 675 Mass
-Ave, Cambridge, MA 02139, USA.
-=end
+# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
+# redistribute it and/or modify it under the same terms of Ruby's license;
+# either the dual license version in 2003, or any later version.
require 'wsdl/parser'
@@ -43,6 +32,10 @@ class WSDLDriverFactory
@logdev = logdev
@wsdl = import(wsdl)
end
+
+ def inspect
+ "#<#{self.class}:#{@wsdl.name}>"
+ end
def create_driver(servicename = nil, portname = nil, opt = {})
service = if servicename
@@ -105,6 +98,7 @@ class WSDLDriver
__attr_proxy :wiredump_dev, true
__attr_proxy :wiredump_file_base, true
__attr_proxy :httpproxy, true
+ __attr_proxy :mandatorycharset, true # force using charset
__attr_proxy :default_encodingstyle, true
__attr_proxy :allow_unqualified_element, true
@@ -121,14 +115,16 @@ class WSDLDriver
include Logger::Severity
include SOAP
+ attr_reader :wsdl
+ attr_reader :port
attr_reader :opt
attr_accessor :logdev
attr_accessor :mapping_registry
attr_accessor :wsdl_mapping_registry
- attr_reader :endpoint_url
attr_reader :wiredump_dev
attr_reader :wiredump_file_base
attr_reader :httpproxy
+ attr_accessor :mandatorycharset
attr_accessor :default_encodingstyle
attr_accessor :allow_unqualified_element
@@ -220,11 +216,9 @@ class WSDLDriver
@opt = opt.dup
@mapping_registry = nil # for rpc unmarshal
@wsdl_mapping_registry = nil # for rpc marshal
- @endpoint_url = nil
@wiredump_dev = nil
@wiredump_file_base = nil
- name = 'http_proxy'
- @httpproxy = ENV[name] || ENV[name.upcase]
+ @mandatorycharset = nil
@wsdl_elements = @wsdl.collect_elements
@wsdl_types = @wsdl.collect_complextypes
@@ -235,7 +229,8 @@ class WSDLDriver
@allow_unqualified_element = true
@generate_explicit_type = false
- create_handler
+ create_streamhandler(@port.soap_address.location,
+ ENV['http_proxy'] || ENV['HTTP_PROXY'])
@operations = {}
# Convert a map which key is QName, to a Hash which key is String.
@port.inputoperation_map.each do |op_name, op_info|
@@ -244,21 +239,20 @@ class WSDLDriver
end
end
+ def endpoint_url
+ @streamhandler.endpoint_url
+ end
+
def endpoint_url=(endpoint_url)
- @endpoint_url = endpoint_url
- if @handler
- @handler.endpoint_url = @endpoint_url
- @handler.reset
- end
- log(DEBUG) { "endpoint_url=: set endpoint_url #{ @endpoint_url }." }
+ @streamhandler.endpoint_url = endpoint_url
+ @streamhandler.reset
+ log(DEBUG) { "endpoint_url=: set endpoint_url #{ endpoint_url }." }
end
def wiredump_dev=(dev)
@wiredump_dev = dev
- if @handler
- @handler.wiredump_dev = @wiredump_dev
- @handler.reset
- end
+ @streamhandler.wiredump_dev = @wiredump_dev
+ @streamhandler.reset
end
def wiredump_file_base=(base)
@@ -266,16 +260,13 @@ class WSDLDriver
end
def httpproxy=(httpproxy)
- @httpproxy = httpproxy
- if @handler
- @handler.proxy = @httpproxy
- @handler.reset
- end
- log(DEBUG) { "httpproxy=: set httpproxy #{ @httpproxy }." }
+ @streamhandler.proxy = httpproxy
+ @streamhandler.reset
+ log(DEBUG) { "httpproxy=: set httpproxy #{ httpproxy }." }
end
def reset_stream
- @handler.reset
+ @streamhandler.reset
end
def rpc_send(method_name, *params)
@@ -292,7 +283,8 @@ class WSDLDriver
req_body = SOAPBody.new(method)
if @wiredump_file_base
- @handler.wiredump_file_base = @wiredump_file_base + '_' << method_name
+ @streamhandler.wiredump_file_base =
+ @wiredump_file_base + '_' << method_name
end
begin
@@ -338,11 +330,10 @@ class WSDLDriver
private
- def create_handler
- endpoint_url = @endpoint_url || @port.soap_address.location
- @handler = HTTPPostStreamHandler.new(endpoint_url, @httpproxy,
+ def create_streamhandler(endpoint_url, httpproxy)
+ @streamhandler = HTTPPostStreamHandler.new(endpoint_url, httpproxy,
XSD::Charset.encoding_label)
- @handler.wiredump_dev = @wiredump_dev
+ @streamhandler.wiredump_dev = @wiredump_dev
end
def create_method_obj(names, params)
@@ -356,13 +347,13 @@ class WSDLDriver
def invoke(req_header, req_body, op_info, opt)
send_string = Processor.marshal(req_header, req_body, opt)
log(DEBUG) { "invoke: sending string #{ send_string }" }
- data = @handler.send(send_string, op_info.soapaction)
+ data = @streamhandler.send(send_string, op_info.soapaction)
log(DEBUG) { "invoke: received string #{ data.receive_string }" }
if data.receive_string.empty?
return nil, nil
end
- res_charset = StreamHandler.parse_media_type(data.receive_contenttype)
- opt[:charset] = res_charset
+ 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
end
@@ -483,6 +474,10 @@ class WSDLDriver
def initialize(wsdl, port, logdev, opt)
@servant = Servant__.new(self, wsdl, port, logdev, opt)
end
+
+ def inspect
+ "#<#{self.class}:#{@servant.port.name}>"
+ end
end