PageRenderTime 47ms CodeModel.GetById 41ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/Ruby/lib/ruby/1.8/wsdl/soap/header.rb

http://github.com/agross/netopenspace
Ruby | 86 lines | 65 code | 16 blank | 5 comment | 3 complexity | 8db963995806f14ae9cdc565acda01bc MD5 | raw file
 1# WSDL4R - WSDL SOAP body definition.
 2# Copyright (C) 2002, 2003  NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
 3
 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.
 7
 8
 9require 'wsdl/info'
10
11
12module WSDL
13module SOAP
14
15
16class Header < Info
17  attr_reader :headerfault
18
19  attr_reader :message	# required
20  attr_reader :part	# required
21  attr_reader :use	# required
22  attr_reader :encodingstyle
23  attr_reader :namespace
24
25  def initialize
26    super
27    @message = nil
28    @part = nil
29    @use = nil
30    @encodingstyle = nil
31    @namespace = nil
32    @headerfault = nil
33  end
34
35  def targetnamespace
36    parent.targetnamespace
37  end
38
39  def find_message
40    root.message(@message) or raise RuntimeError.new("#{@message} not found")
41  end
42
43  def find_part
44    find_message.parts.each do |part|
45      if part.name == @part
46	return part
47      end
48    end
49    raise RuntimeError.new("#{@part} not found")
50  end
51
52  def parse_element(element)
53    case element
54    when HeaderFaultName
55      o = WSDL::SOAP::HeaderFault.new
56      @headerfault = o
57      o
58    else
59      nil
60    end
61  end
62
63  def parse_attr(attr, value)
64    case attr
65    when MessageAttrName
66      if value.namespace.nil?
67        value = XSD::QName.new(targetnamespace, value.source)
68      end
69      @message = value
70    when PartAttrName
71      @part = value.source
72    when UseAttrName
73      @use = value.source
74    when EncodingStyleAttrName
75      @encodingstyle = value.source
76    when NamespaceAttrName
77      @namespace = value.source
78    else
79      nil
80    end
81  end
82end
83
84
85end
86end