Parent

Files

Class Index [+]

Quicksearch

WSDL::Definitions

Attributes

name[R]
targetnamespace[R]
imports[R]
location[RW]
importedschema[R]

Public Class Methods

array_complextype() click to toggle source
    # File lib/wsdl/soap/definitions.rb, line 26
26:   def self.array_complextype
27:     type = XMLSchema::ComplexType.new(::SOAP::ValueArrayName)
28:     type.complexcontent = XMLSchema::ComplexContent.new
29:     type.complexcontent.restriction = XMLSchema::ComplexRestriction.new
30:     type.complexcontent.restriction.base = ::SOAP::ValueArrayName
31:     attr = XMLSchema::Attribute.new
32:     attr.ref = ::SOAP::AttrArrayTypeName
33:     anyarray = XSD::QName.new(
34:       XSD::AnyTypeName.namespace,
35:       XSD::AnyTypeName.name + '[]')
36:     attr.arytype = anyarray
37:     type.complexcontent.restriction.attributes << attr
38:     type
39:   end
exception_complextype() click to toggle source
    # File lib/wsdl/soap/definitions.rb, line 64
64:   def self.exception_complextype
65:     type = XMLSchema::ComplexType.new(XSD::QName.new(
66:         ::SOAP::Mapping::RubyCustomTypeNamespace, 'SOAPException'))
67:     excn_name = XMLSchema::Element.new(XSD::QName.new(nil, 'excn_type_name'), XSD::XSDString::Type)
68:     cause = XMLSchema::Element.new(XSD::QName.new(nil, 'cause'), XSD::AnyTypeName)
69:     backtrace = XMLSchema::Element.new(XSD::QName.new(nil, 'backtrace'), ::SOAP::ValueArrayName)
70:     message = XMLSchema::Element.new(XSD::QName.new(nil, 'message'), XSD::XSDString::Type)
71:     type.all_elements = [excn_name, cause, backtrace, message]
72:     type
73:   end
fault_complextype() click to toggle source
    # File lib/wsdl/soap/definitions.rb, line 51
51:   def self.fault_complextype
52:     type = XMLSchema::ComplexType.new(::SOAP::EleFaultName)
53:     faultcode = XMLSchema::Element.new(::SOAP::EleFaultCodeName, XSD::XSDQName::Type)
54:     faultstring = XMLSchema::Element.new(::SOAP::EleFaultStringName, XSD::XSDString::Type)
55:     faultactor = XMLSchema::Element.new(::SOAP::EleFaultActorName, XSD::XSDAnyURI::Type)
56:     faultactor.minoccurs = 0
57:     detail = XMLSchema::Element.new(::SOAP::EleFaultDetailName, XSD::AnyTypeName)
58:     detail.minoccurs = 0
59:     type.all_elements = [faultcode, faultstring, faultactor, detail]
60:     type.final = 'extension'
61:     type
62:   end
new() click to toggle source
    # File lib/wsdl/definitions.rb, line 24
24:   def initialize
25:     super
26:     @name = nil
27:     @targetnamespace = nil
28:     @location = nil
29:     @importedschema = {}
30: 
31:     @types = nil
32:     @imports = []
33:     @messages = XSD::NamedElements.new
34:     @porttypes = XSD::NamedElements.new
35:     @bindings = XSD::NamedElements.new
36:     @services = XSD::NamedElements.new
37: 
38:     @anontypes = XSD::NamedElements.new
39:     @root = self
40:   end
parse_element(element) click to toggle source
     # File lib/wsdl/definitions.rb, line 210
210:   def self.parse_element(element)
211:     if element == DefinitionsName
212:       Definitions.new
213:     else
214:       nil
215:     end
216:   end
soap_rpc_complextypes() click to toggle source
    # File lib/wsdl/soap/definitions.rb, line 18
18:   def self.soap_rpc_complextypes
19:     types = XSD::NamedElements.new
20:     types << array_complextype
21:     types << fault_complextype
22:     types << exception_complextype
23:     types
24:   end

Public Instance Methods

add_type(complextype) click to toggle source

ToDo: simpletype must be accepted...

    # File lib/wsdl/definitions.rb, line 79
79:   def add_type(complextype)
80:     @anontypes << complextype
81:   end
binding(name) click to toggle source
     # File lib/wsdl/definitions.rb, line 135
135:   def binding(name)
136:     binding = @bindings[name]
137:     return binding if binding
138:     @imports.each do |import|
139:       binding = import.content.binding(name) if self.class === import.content
140:       return binding if binding
141:     end
142:     nil
143:   end
bindings() click to toggle source
     # File lib/wsdl/definitions.rb, line 99
 99:   def bindings
100:     result = @bindings.dup
101:     @imports.each do |import|
102:       result.concat(import.content.bindings) if self.class === import.content
103:     end
104:     result
105:   end
collect_attributegroups() click to toggle source
    # File lib/wsdl/definitions.rb, line 61
61:   def collect_attributegroups
62:     collect_imports(:collect_attributegroups)
63:   end
collect_attributes() click to toggle source
    # File lib/wsdl/definitions.rb, line 53
53:   def collect_attributes
54:     collect_imports(:collect_attributes)
55:   end
collect_complextypes() click to toggle source
    # File lib/wsdl/definitions.rb, line 69
69:   def collect_complextypes
70:     result = collect_imports(:collect_complextypes)
71:     @anontypes.dup.concat(result)
72:   end
collect_elements() click to toggle source
    # File lib/wsdl/definitions.rb, line 65
65:   def collect_elements
66:     collect_imports(:collect_elements)
67:   end
collect_faulttypes() click to toggle source
     # File lib/wsdl/soap/definitions.rb, line 80
 80:   def collect_faulttypes
 81:     result = []
 82:     collect_fault_messages.each do |name|
 83:       faultparts = message(name).parts
 84:       if faultparts.size != 1
 85:         raise RuntimeError.new("Expecting fault message \"#{name}\" to have ONE part")
 86:       end
 87:       fault_part = faultparts[0]
 88:       # WS-I Basic Profile Version 1.1 (R2205) requires fault message parts 
 89:       # to refer to elements rather than types
 90:       faulttype = fault_part.element
 91:       if not faulttype
 92:         warn("Fault message \"#{name}\" part \"#{fault_part.name}\" must specify an \"element\" attribute")
 93:         faulttype = fault_part.type
 94:       end
 95:       if faulttype and result.index(faulttype).nil?
 96:         result << faulttype
 97:       end
 98:     end
 99:     result
100:   end
collect_modelgroups() click to toggle source
    # File lib/wsdl/definitions.rb, line 57
57:   def collect_modelgroups
58:     collect_imports(:collect_modelgroups)
59:   end
collect_simpletypes() click to toggle source
    # File lib/wsdl/definitions.rb, line 74
74:   def collect_simpletypes
75:     collect_imports(:collect_simpletypes)
76:   end
inspect() click to toggle source
    # File lib/wsdl/definitions.rb, line 42
42:   def inspect
43:     sprintf("#<%s:0x%x %s>", self.class.name, __id__, @name || '(unnamed)')
44:   end
message(name) click to toggle source
     # File lib/wsdl/definitions.rb, line 115
115:   def message(name)
116:     message = @messages[name]
117:     return message if message
118:     @imports.each do |import|
119:       message = import.content.message(name) if self.class === import.content
120:       return message if message
121:     end
122:     nil
123:   end
messages() click to toggle source
    # File lib/wsdl/definitions.rb, line 83
83:   def messages
84:     result = @messages.dup
85:     @imports.each do |import|
86:       result.concat(import.content.messages) if self.class === import.content
87:     end
88:     result
89:   end
parse_attr(attr, value) click to toggle source
     # File lib/wsdl/definitions.rb, line 199
199:   def parse_attr(attr, value)
200:     case attr
201:     when NameAttrName
202:       @name = XSD::QName.new(targetnamespace, value.source)
203:     when TargetNamespaceAttrName
204:       self.targetnamespace = value.source
205:     else
206:       nil
207:     end
208:   end
parse_element(element) click to toggle source
     # File lib/wsdl/definitions.rb, line 165
165:   def parse_element(element)
166:     case element
167:     when ImportName
168:       o = Import.new
169:       @imports << o
170:       o
171:     when TypesName
172:       o = Types.new
173:       @types = o
174:       o
175:     when MessageName
176:       o = Message.new
177:       @messages << o
178:       o
179:     when PortTypeName
180:       o = PortType.new
181:       @porttypes << o
182:       o
183:     when BindingName
184:       o = Binding.new
185:       @bindings << o
186:       o
187:     when ServiceName
188:       o = Service.new
189:       @services << o
190:       o
191:     when DocumentationName
192:       o = Documentation.new
193:       o
194:     else
195:       nil
196:     end
197:   end
porttype(name) click to toggle source
     # File lib/wsdl/definitions.rb, line 125
125:   def porttype(name)
126:     porttype = @porttypes[name]
127:     return porttype if porttype
128:     @imports.each do |import|
129:       porttype = import.content.porttype(name) if self.class === import.content
130:       return porttype if porttype
131:     end
132:     nil
133:   end
porttype_binding(name) click to toggle source
     # File lib/wsdl/definitions.rb, line 155
155:   def porttype_binding(name)
156:     binding = @bindings.find { |item| item.type == name }
157:     return binding if binding
158:     @imports.each do |import|
159:       binding = import.content.porttype_binding(name) if self.class === import.content
160:       return binding if binding
161:     end
162:     nil
163:   end
porttypes() click to toggle source
    # File lib/wsdl/definitions.rb, line 91
91:   def porttypes
92:     result = @porttypes.dup
93:     @imports.each do |import|
94:       result.concat(import.content.porttypes) if self.class === import.content
95:     end
96:     result
97:   end
service(name) click to toggle source
     # File lib/wsdl/definitions.rb, line 145
145:   def service(name)
146:     service = @services[name]
147:     return service if service
148:     @imports.each do |import|
149:       service = import.content.service(name) if self.class === import.content
150:       return service if service
151:     end
152:     nil
153:   end
services() click to toggle source
     # File lib/wsdl/definitions.rb, line 107
107:   def services
108:     result = @services.dup
109:     @imports.each do |import|
110:       result.concat(import.content.services) if self.class === import.content
111:     end
112:     result
113:   end
soap_rpc_complextypes(binding) click to toggle source
    # File lib/wsdl/soap/definitions.rb, line 75
75:   def soap_rpc_complextypes(binding)
76:     types = rpc_operation_complextypes(binding)
77:     types + self.class.soap_rpc_complextypes
78:   end
targetnamespace=(targetnamespace) click to toggle source
    # File lib/wsdl/definitions.rb, line 46
46:   def targetnamespace=(targetnamespace)
47:     @targetnamespace = targetnamespace
48:     if @name
49:       @name = XSD::QName.new(@targetnamespace, @name.name)
50:     end
51:   end

Private Instance Methods

collect_fault_messages() click to toggle source
     # File lib/wsdl/soap/definitions.rb, line 115
115:   def collect_fault_messages
116:     result = []
117:     porttypes.each do |porttype|
118:       port_binding = porttype.find_binding()
119:       next unless port_binding
120:       porttype.operations.each do |operation|
121:         op_binding = port_binding.operations.find { |ele| ele.name == operation.name }
122:         next unless op_binding
123:         operation.fault.each do |fault|
124:           # Make sure the operation fault has a name
125:           if not fault.name
126:             warn("Operation \"#{operation.name}\": fault must specify a \"name\" attribute")
127:             next
128:           end
129:           # Make sure that portType fault has a corresponding soap:fault
130:           # definition in binding section.
131:           if not op_binding_declares_fault(op_binding, fault.name)
132:             warn("Operation \"#{operation.name}\", fault \"#{fault.name}\": no corresponding wsdl:fault binding found with a matching \"name\" attribute")          
133:             next
134:           end
135:           fault_binding = get_fault_binding(op_binding, fault.name)
136:           if fault_binding.soapfault.nil?
137:             warn("WARNING: no soap:fault found for wsdl:fault \"#{fault_binding.name}\" in operation \"#{operation.name}\" \n\n")
138:             next
139:           end
140:           if fault_binding.soapfault.name != fault_binding.name
141:             warn("WARNING: name of soap:fault \"#{fault_binding.soapfault.name}\" doesn't match the name of wsdl:fault \"#{fault_binding.name}\" in operation \"#{operation.name}\" \n\n")
142:             next
143:           end
144:           # According to WS-I (R2723): if in a wsdl:binding the use attribute
145:           # on a contained soapbind:fault element is present, its value MUST 
146:           # be "literal".          
147:           if fault_binding.soapfault.use and fault_binding.soapfault.use != "literal"
148:             warn("Operation \"#{operation.name}\", fault \"#{fault.name}\": soap:fault \"use\" attribute must be \"literal\"")          
149:           end
150:           if result.index(fault.message).nil?
151:             result << fault.message
152:           end
153:         end
154:       end
155:     end
156:     result
157:   end
collect_imports(method) click to toggle source
     # File lib/wsdl/definitions.rb, line 220
220:   def collect_imports(method)
221:     result = XSD::NamedElements.new
222:     if @types
223:       @types.schemas.each do |schema|
224:         result.concat(schema.send(method))
225:       end
226:     end
227:     @imports.each do |import|
228:       result.concat(import.content.send(method))
229:     end
230:     result
231:   end
elements_from_message(message) click to toggle source
     # File lib/wsdl/soap/definitions.rb, line 185
185:   def elements_from_message(message)
186:     message.parts.collect { |part|
187:       if part.element
188:         collect_elements[part.element]
189:       elsif part.name.nil? or part.type.nil?
190:         raise RuntimeError.new("part of a message must be an element or typed")
191:       else
192:         qname = XSD::QName.new(nil, part.name)
193:         XMLSchema::Element.new(qname, part.type)
194:       end
195:     }
196:   end
get_fault_binding(op_binding, fault_name) click to toggle source
     # File lib/wsdl/soap/definitions.rb, line 104
104:   def get_fault_binding(op_binding, fault_name)
105:     op_binding.fault.each do |fault|
106:       return fault if fault.name == fault_name
107:     end
108:     return nil
109:   end
op_bind_rpc?(op_bind) click to toggle source
     # File lib/wsdl/soap/definitions.rb, line 181
181:   def op_bind_rpc?(op_bind)
182:     op_bind.soapoperation_style == :rpc
183:   end
op_binding_declares_fault(op_binding, fault_name) click to toggle source
     # File lib/wsdl/soap/definitions.rb, line 111
111:   def op_binding_declares_fault(op_binding, fault_name)
112:     return get_fault_binding(op_binding, fault_name) != nil
113:   end
rpc_operation_complextypes(binding) click to toggle source
     # File lib/wsdl/soap/definitions.rb, line 159
159:   def rpc_operation_complextypes(binding)
160:     types = XSD::NamedElements.new
161:     binding.operations.each do |op_bind|
162:       if op_bind_rpc?(op_bind)
163:         operation = op_bind.find_operation
164:         if op_bind.input
165:           type = XMLSchema::ComplexType.new(op_bind.soapoperation_name)
166:           message = messages[operation.input.message]
167:           type.sequence_elements = elements_from_message(message)
168:           types << type
169:         end
170:         if op_bind.output
171:           type = XMLSchema::ComplexType.new(operation.outputname)
172:           message = messages[operation.output.message]
173:           type.sequence_elements = elements_from_message(message)
174:           types << type
175:         end
176:       end
177:     end
178:     types
179:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.