mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
20fa0df5cd
such as HTTP_PROXY. * lib/soap/property.rb: property implementation. * lib/soap/streamHandler.rb, lib/soap/wsdlDriver.rb, lib/soap/rpc/driver.rb: use soap/property.rb. * lib/wsdl/importer.rb, lib/soap/wsdlDriver.rb, lib/soap/rpc/driver.rb: use SOAP::Env. * lib/soap/netHttpClient.rb: add basic_auth, ssl_config, and cookie management interface, but ignored for now. * lib/xsd/charset.rb: add XSD::Charset.encoding= interface to set wiredump charset explicitly. it was fixed to 'utf-8' when iconv or uconv module was found. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
72 lines
1.5 KiB
Ruby
72 lines
1.5 KiB
Ruby
# WSDL4R - WSDL importer library.
|
|
# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
|
|
|
# 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/info'
|
|
require 'wsdl/parser'
|
|
require 'soap/soap'
|
|
|
|
|
|
module WSDL
|
|
|
|
|
|
class Importer
|
|
def self.import(location)
|
|
new.import(location)
|
|
end
|
|
|
|
def initialize
|
|
@web_client = nil
|
|
end
|
|
|
|
def import(location)
|
|
content = nil
|
|
if FileTest.exist?(location)
|
|
content = File.open(location).read
|
|
else
|
|
client = web_client.new(nil, "WSDL4R")
|
|
if env_httpproxy = ::SOAP::Env::HTTP_PROXY
|
|
client.proxy = env_httpproxy
|
|
end
|
|
if env_no_proxy = ::SOAP::Env::NO_PROXY
|
|
client.no_proxy = env_no_proxy
|
|
end
|
|
content = client.get_content(location)
|
|
end
|
|
opt = {} # charset?
|
|
begin
|
|
WSDL::Parser.new(opt).parse(content)
|
|
rescue WSDL::Parser::ParseError => orgexcn
|
|
begin
|
|
require 'wsdl/xmlSchema/parser'
|
|
WSDL::XMLSchema::Parser.new(opt).parse(content)
|
|
rescue
|
|
raise orgexcn
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def web_client
|
|
@web_client ||= begin
|
|
require 'http-access2'
|
|
if HTTPAccess2::VERSION < "2.0"
|
|
raise LoadError.new("http-access/2.0 or later is required.")
|
|
end
|
|
HTTPAccess2::Client
|
|
rescue LoadError
|
|
STDERR.puts "Loading http-access2 failed. Net/http is used." if $DEBUG
|
|
require 'soap/netHttpClient'
|
|
::SOAP::NetHttpClient
|
|
end
|
|
@web_client
|
|
end
|
|
end
|
|
|
|
|
|
end
|