1
# WSDL4R - XSD importer library.
2
# Copyright (C) 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
5
# redistribute it and/or modify it under the same terms of Ruby's license;
6
# either the dual license version in 2003, or any later version.
9
require 'soap/httpconfigloader'
10
require 'wsdl/xmlSchema/parser'
18
def self.import(location, originalroot = nil)
19
new.import(location, originalroot)
26
def import(location, originalroot = nil)
27
unless location.is_a?(URI)
28
location = URI.parse(location)
30
content = parse(fetch(location), location, originalroot)
31
content.location = location
37
def parse(content, location, originalroot)
39
:location => location,
40
:originalroot => originalroot
42
WSDL::XMLSchema::Parser.new(opt).parse(content)
46
warn("importing: #{location}") if $DEBUG
48
if location.scheme == 'file' or
49
(location.relative? and FileTest.exist?(location.path))
50
content = File.open(location.path).read
51
elsif location.scheme and location.scheme.size == 1 and
52
FileTest.exist?(location.to_s)
53
# ToDo: remove this ugly workaround for a path with drive letter
55
content = File.open(location.to_s).read
57
client = web_client.new(nil, "WSDL4R")
58
client.proxy = ::SOAP::Env::HTTP_PROXY
59
client.no_proxy = ::SOAP::Env::NO_PROXY
60
if opt = ::SOAP::Property.loadproperty(::SOAP::PropertyName)
61
::SOAP::HTTPConfigLoader.set_options(client,
62
opt["client.protocol.http"])
64
content = client.get_content(location)
71
require 'http-access2'
72
if HTTPAccess2::VERSION < "2.0"
73
raise LoadError.new("http-access/2.0 or later is required.")
77
warn("Loading http-access2 failed. Net/http is used.") if $DEBUG
78
require 'soap/netHttpClient'