class WSDL::Definitions
Attributes
importedschema[R]
imports[R]
location[RW]
name[R]
targetnamespace[R]
Public Class Methods
array_complextype()
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 26 def self.array_complextype type = XMLSchema::ComplexType.new(::SOAP::ValueArrayName) type.complexcontent = XMLSchema::ComplexContent.new type.complexcontent.restriction = XMLSchema::ComplexRestriction.new type.complexcontent.restriction.base = ::SOAP::ValueArrayName attr = XMLSchema::Attribute.new attr.ref = ::SOAP::AttrArrayTypeName anyarray = XSD::QName.new( XSD::AnyTypeName.namespace, XSD::AnyTypeName.name + '[]') attr.arytype = anyarray type.complexcontent.restriction.attributes << attr type end
exception_complextype()
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 64 def self.exception_complextype type = XMLSchema::ComplexType.new(XSD::QName.new( ::SOAP::Mapping::RubyCustomTypeNamespace, 'SOAPException')) excn_name = XMLSchema::Element.new(XSD::QName.new(nil, 'excn_type_name'), XSD::XSDString::Type) cause = XMLSchema::Element.new(XSD::QName.new(nil, 'cause'), XSD::AnyTypeName) backtrace = XMLSchema::Element.new(XSD::QName.new(nil, 'backtrace'), ::SOAP::ValueArrayName) message = XMLSchema::Element.new(XSD::QName.new(nil, 'message'), XSD::XSDString::Type) type.all_elements = [excn_name, cause, backtrace, message] type end
fault_complextype()
click to toggle source
<xs:complexType name=“Fault” final=“extension”>
<xs:sequence> <xs:element name="faultcode" type="xs:QName" /> <xs:element name="faultstring" type="xs:string" /> <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" /> <xs:element name="detail" type="tns:detail" minOccurs="0" /> </xs:sequence>
</xs:complexType>
# File lib/wsdl/soap/definitions.rb, line 51 def self.fault_complextype type = XMLSchema::ComplexType.new(::SOAP::EleFaultName) faultcode = XMLSchema::Element.new(::SOAP::EleFaultCodeName, XSD::XSDQName::Type) faultstring = XMLSchema::Element.new(::SOAP::EleFaultStringName, XSD::XSDString::Type) faultactor = XMLSchema::Element.new(::SOAP::EleFaultActorName, XSD::XSDAnyURI::Type) faultactor.minoccurs = 0 detail = XMLSchema::Element.new(::SOAP::EleFaultDetailName, XSD::AnyTypeName) detail.minoccurs = 0 type.all_elements = [faultcode, faultstring, faultactor, detail] type.final = 'extension' type end
new()
click to toggle source
Calls superclass method
# File lib/wsdl/definitions.rb, line 24 def initialize super @name = nil @targetnamespace = nil @location = nil @importedschema = {} @types = nil @imports = [] @messages = XSD::NamedElements.new @porttypes = XSD::NamedElements.new @bindings = XSD::NamedElements.new @services = XSD::NamedElements.new @anontypes = XSD::NamedElements.new @root = self end
parse_element(element)
click to toggle source
# File lib/wsdl/definitions.rb, line 210 def self.parse_element(element) if element == DefinitionsName Definitions.new else nil end end
soap_rpc_complextypes()
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 18 def self.soap_rpc_complextypes types = XSD::NamedElements.new types << array_complextype types << fault_complextype types << exception_complextype types end
Public Instance Methods
add_type(complextype)
click to toggle source
ToDo: simpletype must be accepted…
# File lib/wsdl/definitions.rb, line 79 def add_type(complextype) @anontypes << complextype end
binding(name)
click to toggle source
# File lib/wsdl/definitions.rb, line 135 def binding(name) binding = @bindings[name] return binding if binding @imports.each do |import| binding = import.content.binding(name) if self.class === import.content return binding if binding end nil end
bindings()
click to toggle source
# File lib/wsdl/definitions.rb, line 99 def bindings result = @bindings.dup @imports.each do |import| result.concat(import.content.bindings) if self.class === import.content end result end
collect_attributegroups()
click to toggle source
# File lib/wsdl/definitions.rb, line 61 def collect_attributegroups collect_imports(:collect_attributegroups) end
collect_attributes()
click to toggle source
# File lib/wsdl/definitions.rb, line 53 def collect_attributes collect_imports(:collect_attributes) end
collect_complextypes()
click to toggle source
# File lib/wsdl/definitions.rb, line 69 def collect_complextypes result = collect_imports(:collect_complextypes) @anontypes.dup.concat(result) end
collect_elements()
click to toggle source
# File lib/wsdl/definitions.rb, line 65 def collect_elements collect_imports(:collect_elements) end
collect_faulttypes()
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 80 def collect_faulttypes result = [] collect_fault_messages.each do |name| faultparts = message(name).parts if faultparts.size != 1 raise RuntimeError.new("Expecting fault message \"#{name}\" to have ONE part") end fault_part = faultparts[0] # WS-I Basic Profile Version 1.1 (R2205) requires fault message parts # to refer to elements rather than types faulttype = fault_part.element if not faulttype warn("Fault message \"#{name}\" part \"#{fault_part.name}\" must specify an \"element\" attribute") faulttype = fault_part.type end if faulttype and result.index(faulttype).nil? result << faulttype end end result end
collect_modelgroups()
click to toggle source
# File lib/wsdl/definitions.rb, line 57 def collect_modelgroups collect_imports(:collect_modelgroups) end
collect_simpletypes()
click to toggle source
# File lib/wsdl/definitions.rb, line 74 def collect_simpletypes collect_imports(:collect_simpletypes) end
inspect()
click to toggle source
# File lib/wsdl/definitions.rb, line 42 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, @name || '(unnamed)') end
message(name)
click to toggle source
# File lib/wsdl/definitions.rb, line 115 def message(name) message = @messages[name] return message if message @imports.each do |import| message = import.content.message(name) if self.class === import.content return message if message end nil end
messages()
click to toggle source
# File lib/wsdl/definitions.rb, line 83 def messages result = @messages.dup @imports.each do |import| result.concat(import.content.messages) if self.class === import.content end result end
parse_attr(attr, value)
click to toggle source
# File lib/wsdl/definitions.rb, line 199 def parse_attr(attr, value) case attr when NameAttrName @name = XSD::QName.new(targetnamespace, value.source) when TargetNamespaceAttrName self.targetnamespace = value.source else nil end end
parse_element(element)
click to toggle source
# File lib/wsdl/definitions.rb, line 165 def parse_element(element) case element when ImportName o = Import.new @imports << o o when TypesName o = Types.new @types = o o when MessageName o = Message.new @messages << o o when PortTypeName o = PortType.new @porttypes << o o when BindingName o = Binding.new @bindings << o o when ServiceName o = Service.new @services << o o when DocumentationName o = Documentation.new o else nil end end
porttype(name)
click to toggle source
# File lib/wsdl/definitions.rb, line 125 def porttype(name) porttype = @porttypes[name] return porttype if porttype @imports.each do |import| porttype = import.content.porttype(name) if self.class === import.content return porttype if porttype end nil end
porttype_binding(name)
click to toggle source
# File lib/wsdl/definitions.rb, line 155 def porttype_binding(name) binding = @bindings.find { |item| item.type == name } return binding if binding @imports.each do |import| binding = import.content.porttype_binding(name) if self.class === import.content return binding if binding end nil end
porttypes()
click to toggle source
# File lib/wsdl/definitions.rb, line 91 def porttypes result = @porttypes.dup @imports.each do |import| result.concat(import.content.porttypes) if self.class === import.content end result end
service(name)
click to toggle source
# File lib/wsdl/definitions.rb, line 145 def service(name) service = @services[name] return service if service @imports.each do |import| service = import.content.service(name) if self.class === import.content return service if service end nil end
services()
click to toggle source
# File lib/wsdl/definitions.rb, line 107 def services result = @services.dup @imports.each do |import| result.concat(import.content.services) if self.class === import.content end result end
soap_rpc_complextypes(binding)
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 75 def soap_rpc_complextypes(binding) types = rpc_operation_complextypes(binding) types + self.class.soap_rpc_complextypes end
targetnamespace=(targetnamespace)
click to toggle source
# File lib/wsdl/definitions.rb, line 46 def targetnamespace=(targetnamespace) @targetnamespace = targetnamespace if @name @name = XSD::QName.new(@targetnamespace, @name.name) end end
Private Instance Methods
collect_fault_messages()
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 115 def collect_fault_messages result = [] porttypes.each do |porttype| port_binding = porttype.find_binding() next unless port_binding porttype.operations.each do |operation| op_binding = port_binding.operations.find { |ele| ele.name == operation.name } next unless op_binding operation.fault.each do |fault| # Make sure the operation fault has a name if not fault.name warn("Operation \"#{operation.name}\": fault must specify a \"name\" attribute") next end # Make sure that portType fault has a corresponding soap:fault # definition in binding section. if not op_binding_declares_fault(op_binding, fault.name) warn("Operation \"#{operation.name}\", fault \"#{fault.name}\": no corresponding wsdl:fault binding found with a matching \"name\" attribute") next end fault_binding = get_fault_binding(op_binding, fault.name) if fault_binding.soapfault.nil? warn("WARNING: no soap:fault found for wsdl:fault \"#{fault_binding.name}\" in operation \"#{operation.name}\" \n\n") next end if fault_binding.soapfault.name != fault_binding.name 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") next end # According to WS-I (R2723): if in a wsdl:binding the use attribute # on a contained soapbind:fault element is present, its value MUST # be "literal". if fault_binding.soapfault.use and fault_binding.soapfault.use != "literal" warn("Operation \"#{operation.name}\", fault \"#{fault.name}\": soap:fault \"use\" attribute must be \"literal\"") end if result.index(fault.message).nil? result << fault.message end end end end result end
collect_imports(method)
click to toggle source
# File lib/wsdl/definitions.rb, line 220 def collect_imports(method) result = XSD::NamedElements.new if @types @types.schemas.each do |schema| result.concat(schema.send(method)) end end @imports.each do |import| result.concat(import.content.send(method)) end result end
elements_from_message(message)
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 185 def elements_from_message(message) message.parts.collect { |part| if part.element collect_elements[part.element] elsif part.name.nil? or part.type.nil? raise RuntimeError.new("part of a message must be an element or typed") else qname = XSD::QName.new(nil, part.name) XMLSchema::Element.new(qname, part.type) end } end
get_fault_binding(op_binding, fault_name)
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 104 def get_fault_binding(op_binding, fault_name) op_binding.fault.each do |fault| return fault if fault.name == fault_name end return nil end
op_bind_rpc?(op_bind)
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 181 def op_bind_rpc?(op_bind) op_bind.soapoperation_style == :rpc end
op_binding_declares_fault(op_binding, fault_name)
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 111 def op_binding_declares_fault(op_binding, fault_name) return get_fault_binding(op_binding, fault_name) != nil end
rpc_operation_complextypes(binding)
click to toggle source
# File lib/wsdl/soap/definitions.rb, line 159 def rpc_operation_complextypes(binding) types = XSD::NamedElements.new binding.operations.each do |op_bind| if op_bind_rpc?(op_bind) operation = op_bind.find_operation if op_bind.input type = XMLSchema::ComplexType.new(op_bind.soapoperation_name) message = messages[operation.input.message] type.sequence_elements = elements_from_message(message) types << type end if op_bind.output type = XMLSchema::ComplexType.new(operation.outputname) message = messages[operation.output.message] type.sequence_elements = elements_from_message(message) types << type end end end types end