Changeset 1422
- Timestamp:
- 02/04/05 10:59:47 (4 years ago)
- Files:
-
- trunk/lib/wsdl/importer.rb (modified) (3 diffs)
- trunk/lib/wsdl/xmlSchema/importer.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/wsdl/importer.rb
r1364 r1422 1 1 # WSDL4R - WSDL importer library. 2 # Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.2 # Copyright (C) 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 3 3 4 4 # This program is copyrighted free software by NAKAMURA, Hiroshi. You can … … 7 7 8 8 9 require 'wsdl/ info'9 require 'wsdl/xmlSchema/importer' 10 10 require 'wsdl/parser' 11 require 'soap/soap'12 require 'soap/property'13 11 14 12 … … 16 14 17 15 18 class Importer 16 class Importer < WSDL::XMLSchema::Importer 19 17 def self.import(location) 20 18 new.import(location) 21 19 end 22 20 23 def initialize 24 @web_client = nil 25 end 21 private 26 22 27 def import(location) 28 STDERR.puts("importing: #{location}") if $DEBUG 29 content = nil 30 if FileTest.exist?(location) 31 content = File.open(location).read 32 else 33 client = web_client.new(nil, "WSDL4R") 34 if opt = ::SOAP::Property.loadproperty(::SOAP::PropertyName) 35 client.proxy = opt["client.protocol.http.proxy"] 36 client.no_proxy = opt["client.protocol.http.no_proxy"] 37 end 38 client.proxy ||= ::SOAP::Env::HTTP_PROXY 39 client.no_proxy ||= ::SOAP::Env::NO_PROXY 40 content = client.get_content(location) 41 end 42 opt = {} 23 def parse(content) 43 24 begin 44 WSDL::Parser.new(opt).parse(content) 45 rescue WSDL::Parser::ParseError => orgexcn 46 require 'wsdl/xmlSchema/parser' 47 WSDL::XMLSchema::Parser.new(opt).parse(content) 25 WSDL::Parser.new({}).parse(content) 26 rescue WSDL::Parser::ParseError 27 super(content) 48 28 end 49 29 end 50 30 51 private52 53 def web_client54 @web_client ||= begin55 require 'http-access2'56 if HTTPAccess2::VERSION < "2.0"57 raise LoadError.new("http-access/2.0 or later is required.")58 end59 HTTPAccess2::Client60 rescue LoadError61 STDERR.puts "Loading http-access2 failed. Net/http is used." if $DEBUG62 require 'soap/netHttpClient'63 ::SOAP::NetHttpClient64 end65 @web_client66 end67 31 end 68 32