class LolSoap::WSDLParser
@private
Constants
- SOAP_1_1
- SOAP_1_2
Attributes
doc[R]
Public Class Methods
new(doc)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 293 def initialize(doc) @doc = doc end
parse(raw)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 289 def self.parse(raw) new(Nokogiri::XML::Document.parse(raw)) end
Public Instance Methods
abstract_types()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 316 def abstract_types @abstract_types ||= begin types = {} each_node('xs:complexType[@abstract="true"]') do |node, schema| type = Type.new(self, schema, node) types[type.id] = type_record(type) end types end end
attribute_group(namespace, name)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 350 def attribute_group(namespace, name) find_node namespace, name, AttributeGroup, 'attributeGroup' end
each_node(xpath) { |node, schema| ... }
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 437 def each_node(xpath) schemas.each do |schema_node| schema = Schema.from_node(schema_node) schema_node.xpath(xpath, ns).each do |node| yield node, schema end end end
element(namespace, name)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 346 def element(namespace, name) find_node namespace, name, Element, 'element' end
elements()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 331 def elements @elements ||= begin elements = {} each_node('xs:element') do |node, schema| element = Element.new(self, schema, node) elements[element.id] = { :name => element.name, :namespace => element.namespace, :type => element.type } end elements end end
endpoint()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 297 def endpoint @endpoint ||= CGI.unescape(doc.at_xpath('/d:definitions/d:service/d:port/s:address/@location', ns).to_s) end
find_node(namespace, name, node_class, selector)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 446 def find_node(namespace, name, node_class, selector) target = schemas.xpath("../xs:schema[@targetNamespace='#{namespace}']", ns) target = schemas if target.size == 0 if node = target.at_xpath("xs:#{selector}[@name='#{name.split(':').last}']", ns) schema = Schema.from_node(node.at_xpath('parent::xs:schema', ns)) node_class.new(self, schema, node) end end
messages()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 354 def messages @messages ||= Hash[ doc.xpath('/d:definitions/d:message', ns).map { |msg| [ msg.attribute('name').to_s, Hash[ msg.xpath('d:part', ns).map { |part| [ part.attribute('name').to_s, namespace_and_name(part, part['element']) ] } ] ] } ] end
namespace_and_name(node, prefixed_name, default_namespace = nil)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 425 def namespace_and_name(node, prefixed_name, default_namespace = nil) if prefixed_name.include? ':' prefix, name = prefixed_name.split(':') namespace = node.namespaces.fetch("xmlns:#{prefix}") else name = prefixed_name namespace = default_namespace end [namespace, name] end
ns()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 417 def ns @ns ||= { 'd' => 'http://schemas.xmlsoap.org/wsdl/', 'xs' => 'http://www.w3.org/2001/XMLSchema', 's' => soap_version == '1.2' ? SOAP_1_2 : SOAP_1_1 } end
operations()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 386 def operations @operations ||= begin binding = doc.at_xpath('/d:definitions/d:service/d:port/s:address/../@binding', ns).to_s.split(':').last Hash[ doc.xpath("/d:definitions/d:binding[@name='#{binding}']/d:operation", ns).map do |node| operation = Operation.new(self, node) [ operation.name, { :action => operation.action, :input => { :header => operation.input.header, :body => operation.input.body }, :output => { :header => operation.output.header, :body => operation.output.body } } ] end ] end end
port_type_operations()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 372 def port_type_operations @port_type_operations ||= Hash[ doc.xpath('/d:definitions/d:portType/d:operation', ns).map do |op| [ op.attribute('name').to_s, { :input => op.at_xpath('./d:input/@message', ns).to_s, :output => op.at_xpath('./d:output/@message', ns).to_s } ] end ] end
schemas()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 301 def schemas doc.xpath('/d:definitions/d:types/xs:schema', ns) end
soap_version()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 413 def soap_version @soap_version ||= doc.at_xpath("//s2:*", "s2" => SOAP_1_2) ? '1.2' : '1.1' end
type(namespace, name)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 327 def type(namespace, name) find_node namespace, name, Type, 'complexType' end
types()
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 305 def types @types ||= begin types = {} each_node('xs:complexType[not(@abstract="true")]') do |node, schema| type = Type.new(self, schema, node) types[type.id] = type_record(type) end types end end
Private Instance Methods
type_record(type)
click to toggle source
# File lib/lolsoap/wsdl_parser.rb, line 457 def type_record(type) { :name => type.name, :namespace => type.namespace, :elements => type.elements, :attributes => type.attributes } end