1
# WSDL4R - Creating driver code from WSDL.
2
# Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
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.
10
require 'wsdl/soap/mappingRegistryCreator'
11
require 'wsdl/soap/methodDefCreator'
12
require 'wsdl/soap/classDefCreatorSupport'
21
include ClassDefCreatorSupport
23
attr_reader :definitions
25
def initialize(definitions)
26
@definitions = definitions
29
def dump(porttype = nil)
32
@definitions.porttypes.each do |type|
33
result << dump_porttype(type.name)
37
result = dump_porttype(porttype)
44
def dump_porttype(name)
45
class_name = create_class_name(name)
46
methoddef, types = MethodDefCreator.new(@definitions).dump(name)
47
mr_creator = MappingRegistryCreator.new(@definitions)
48
binding = @definitions.bindings.find { |item| item.type == name }
49
return '' unless binding.soapbinding # not a SOAP binding
50
address = @definitions.porttype(name).locations[0]
52
c = XSD::CodeGen::ClassDef.new(class_name, "::SOAP::RPC::Driver")
53
c.def_require("soap/rpc/driver")
54
c.def_const("MappingRegistry", "::SOAP::Mapping::Registry.new")
55
c.def_const("DefaultEndpointUrl", ndq(address))
56
c.def_code(mr_creator.dump(types))
59
#{methoddef.gsub(/^/, " ")}
62
c.def_method("initialize", "endpoint_url = nil") do
64
endpoint_url ||= DefaultEndpointUrl
65
super(endpoint_url, nil)
66
self.mapping_registry = MappingRegistry
70
c.def_privatemethod("init_methods") do
72
Methods.each do |definitions|
73
opt = definitions.last
74
if opt[:request_style] == :document
75
add_document_operation(*definitions)
77
add_rpc_operation(*definitions)
78
qname = definitions[0]
80
if qname.name != name and qname.name.capitalize == name.capitalize
81
::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|