Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1422

Show
Ignore:
Timestamp:
02/04/05 10:59:47 (4 years ago)
Author:
nahi
Message:

introduce XMLSchema importer and let WSDL importer a derived class.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/wsdl/importer.rb

    r1364 r1422  
    11# 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>. 
    33 
    44# This program is copyrighted free software by NAKAMURA, Hiroshi.  You can 
     
    77 
    88 
    9 require 'wsdl/info
     9require 'wsdl/xmlSchema/importer
    1010require 'wsdl/parser' 
    11 require 'soap/soap' 
    12 require 'soap/property' 
    1311 
    1412 
     
    1614 
    1715 
    18 class Importer 
     16class Importer < WSDL::XMLSchema::Importer 
    1917  def self.import(location) 
    2018    new.import(location) 
    2119  end 
    2220 
    23   def initialize 
    24     @web_client = nil 
    25   end 
     21private 
    2622 
    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) 
    4324    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) 
    4828    end 
    4929  end 
    5030 
    51 private 
    52  
    53   def web_client 
    54     @web_client ||= begin 
    55         require 'http-access2' 
    56         if HTTPAccess2::VERSION < "2.0" 
    57           raise LoadError.new("http-access/2.0 or later is required.") 
    58         end 
    59         HTTPAccess2::Client 
    60       rescue LoadError 
    61         STDERR.puts "Loading http-access2 failed.  Net/http is used." if $DEBUG 
    62         require 'soap/netHttpClient' 
    63         ::SOAP::NetHttpClient 
    64       end 
    65     @web_client 
    66   end 
    6731end 
    6832