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

Changeset 761

Show
Ignore:
Timestamp:
01/18/03 02:17:17 (6 years ago)
Author:
nahi
Message:

Load WSDL from the Net with http-access2

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bin/wsdl2ruby.rb

    r697 r761  
    3232  def initialize 
    3333    super( 'app' ) 
    34     @wsdlFile = nil 
     34    STDERR.sync = true 
     35    @wsdlLocation = nil 
    3536    @opt = {} 
    3637    @wsdl = nil 
     
    3940 
    4041  def run 
    41     @wsdlFile, @opt = parseOpt( GetoptLong.new( *OptSet )) 
    42     usageExit unless @wsdlFile 
    43     @wsdl = WSDL::WSDLParser.createParser.parse( File.open( @wsdlFile )
     42    @wsdlLocation, @opt = parseOpt( GetoptLong.new( *OptSet )) 
     43    usageExit unless @wsdlLocation 
     44    @wsdl = import(@wsdlLocation
    4445    @name = @wsdl.name.name || 'default' 
    4546    createFile 
     
    5960  def usageExit 
    6061    puts <<__EOU__ 
    61 Usage: #{ $0 } --wsdl wsdlFilename [options] 
     62Usage: #{ $0 } --wsdl wsdlLocation [options] 
     63  wsdlLocation: filename or URL 
    6264 
    6365Example: 
     
    6870 
    6971Options: 
    70   --wsdl wsdlFilename 
     72  --wsdl wsdlLocation 
    7173  --type server|client 
    7274    --type server implies; 
     
    98100  def parseOpt( getOpt ) 
    99101    opt = {} 
    100     wsdlFile = nil 
     102    wsdl = nil 
    101103    begin 
    102104      getOpt.each do | name, arg | 
    103105        case name 
    104106        when "--wsdl" 
    105           wsdlFile = arg 
     107          wsdl = arg 
    106108        when "--type" 
    107109          case arg 
     
    129131      usageExit 
    130132    end 
    131     return wsdlFile, opt 
     133    return wsdl, opt 
    132134  end 
    133135 
     
    241243    name ? XSD::QName.new( @wsdl.targetNamespace, name ) : nil 
    242244  end 
     245 
     246  def import(location) 
     247    content = nil 
     248    if FileTest.exist?(location) 
     249      content = File.open(location).read 
     250    else 
     251      require 'http-access2' 
     252      c = HTTPAccess2::Client.new(ENV[ 'http_proxy' ] || ENV[ 'HTTP_PROXY' ]) 
     253      content = c.getContent(location) 
     254    end 
     255    WSDL::WSDLParser.createParser.parse(content) 
     256  end 
    243257end 
    244258