diff options
Diffstat (limited to 'test')
35 files changed, 2971 insertions, 14 deletions
diff --git a/test/soap/asp.net/hello.wsdl b/test/soap/asp.net/hello.wsdl new file mode 100644 index 000000000..b94129c15 --- /dev/null +++ b/test/soap/asp.net/hello.wsdl @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="utf-8"?> +<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" +xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" +xmlns:s="http://www.w3.org/2001/XMLSchema" +xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" +xmlns:tns="http://localhost/WebService/" +xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" +xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" +targetNamespace="http://localhost/WebService/" +xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> + <wsdl:types> + <s:schema elementFormDefault="qualified" +targetNamespace="http://localhost/WebService/"> + <s:element name="HelloWorld"> + <s:complexType /> + </s:element> + <s:element name="HelloWorldResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" +name="HelloWorldResult" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="SayHello"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="name" +type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="SayHelloResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" +name="SayHelloResult" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + </s:schema> + </wsdl:types> + <wsdl:message name="HelloWorldSoapIn"> + <wsdl:part name="parameters" element="tns:HelloWorld" /> + </wsdl:message> + <wsdl:message name="HelloWorldSoapOut"> + <wsdl:part name="parameters" element="tns:HelloWorldResponse" /> + </wsdl:message> + <wsdl:message name="SayHelloSoapIn"> + <wsdl:part name="parameters" element="tns:SayHello" /> + </wsdl:message> + <wsdl:message name="SayHelloSoapOut"> + <wsdl:part name="parameters" element="tns:SayHelloResponse" /> + </wsdl:message> + <wsdl:portType name="Service1Soap"> + <wsdl:operation name="HelloWorld"> + <wsdl:input message="tns:HelloWorldSoapIn" /> + <wsdl:output message="tns:HelloWorldSoapOut" /> + </wsdl:operation> + <wsdl:operation name="SayHello"> + <wsdl:input message="tns:SayHelloSoapIn" /> + <wsdl:output message="tns:SayHelloSoapOut" /> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="Service1Soap" type="tns:Service1Soap"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" +style="document" /> + <wsdl:operation name="HelloWorld"> + <soap:operation +soapAction="http://localhost/WebService/HelloWorld" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="SayHello"> + <soap:operation soapAction="http://localhost/WebService/SayHello" +style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="Service1"> + <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" /> + <wsdl:port name="Service1Soap" binding="tns:Service1Soap"> + <soap:address +location="http://localhost/WebService/Service1.asmx" /> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/test/soap/asp.net/test_aspdotnet.rb b/test/soap/asp.net/test_aspdotnet.rb new file mode 100644 index 000000000..7d5f3fd28 --- /dev/null +++ b/test/soap/asp.net/test_aspdotnet.rb @@ -0,0 +1,111 @@ +require 'test/unit' +require 'soap/rpc/standaloneServer' +require 'soap/rpc/driver' + + +module SOAP; module ASPDotNet + + +class TestASPDotNet < Test::Unit::TestCase + class Server < ::SOAP::RPC::StandaloneServer + Namespace = "http://localhost/WebService/" + + def on_init + add_document_method( + self, + Namespace + 'SayHello', + 'sayHello', + XSD::QName.new(Namespace, 'SayHello'), + XSD::QName.new(Namespace, 'SayHelloResponse') + ) + end + + def sayHello(arg) + name = arg['name'] + "Hello #{name}" + end + end + + Port = 17171 + Endpoint = "http://localhost:#{Port}/" + + def setup + setup_server + @client = nil + end + + def teardown + teardown_server + @client.reset_stream if @client + end + + def setup_server + @server = Server.new('Test', Server::Namespace, '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @server_thread = start_server_thread(@server) + end + + def teardown_server + @server.shutdown + @server_thread.kill + @server_thread.join + end + + def start_server_thread(server) + t = Thread.new { + Thread.current.abort_on_exception = true + server.start + } + t + end + + def test_document_method + @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace) + @client.wiredump_dev = STDOUT if $DEBUG + @client.add_document_method('sayHello', Server::Namespace + 'SayHello', + XSD::QName.new(Server::Namespace, 'SayHello'), + XSD::QName.new(Server::Namespace, 'SayHelloResponse')) + assert_equal("Hello Mike", @client.sayHello(:name => "Mike")) + end + + def test_aspdotnethandler + @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace) + @client.wiredump_dev = STDOUT if $DEBUG + @client.add_method_with_soapaction('sayHello', Server::Namespace + 'SayHello', 'name') + @client.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace + assert_equal("Hello Mike", @client.sayHello("Mike")) + end + + if defined?(HTTPAccess2) + + # qualified! + REQUEST_ASPDOTNETHANDLER = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:sayHello xmlns:n1="http://localhost/WebService/"> + <n1:name>Mike</n1:name> + </n1:sayHello> + </env:Body> +</env:Envelope>] + + def test_aspdotnethandler_envelope + @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace) + @client.wiredump_dev = str = '' + @client.add_method_with_soapaction('sayHello', Server::Namespace + 'SayHello', 'name') + @client.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace + assert_equal("Hello Mike", @client.sayHello("Mike")) + assert_equal(REQUEST_ASPDOTNETHANDLER, parse_requestxml(str)) + end + + def parse_requestxml(str) + str.split(/\r?\n\r?\n/)[3] + end + + end +end + + +end; end diff --git a/test/soap/header/test_simplehandler.rb b/test/soap/header/test_simplehandler.rb new file mode 100644 index 000000000..75dbd4a55 --- /dev/null +++ b/test/soap/header/test_simplehandler.rb @@ -0,0 +1,116 @@ +require 'test/unit' +require 'soap/rpc/driver' +require 'soap/rpc/standaloneServer' +require 'soap/header/simplehandler' + + +module SOAP +module Header + + +class TestSimpleHandler < Test::Unit::TestCase + Port = 17171 + PortName = 'http://tempuri.org/authHeaderPort' + + class PingPortServer < SOAP::RPC::StandaloneServer + class PingService + def self.create + new + end + + def ping + Thread.current[:pingheader] + end + end + + def initialize(*arg) + super + add_rpc_servant(PingService.new, PortName) + add_request_headerhandler(PingServerHeaderHandler) + end + + class PingServerHeaderHandler < SOAP::Header::SimpleHandler + MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader") + + def self.create + new + end + + def initialize() + super(MyHeaderName) + end + + def on_simple_outbound + "dummy" + end + + def on_simple_inbound(my_header, mu) + Thread.current[:pingheader] = my_header + end + end + end + + class PingClientHeaderHandler < SOAP::Header::SimpleHandler + MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader") + + def initialize(pingHeader) + super(MyHeaderName) + @pingHeader = pingHeader + @mustunderstand = false + end + + def on_simple_outbound + @pingHeader # --- note, not a Hash + end + + def on_simple_inbound(my_header, mustunderstand) + Thread.current[:pingheader] = my_header + end + end + + def setup + @endpoint = "http://localhost:#{Port}/" + setup_server + setup_client + end + + def setup_server + @server = PingPortServer.new(self.class.name, nil, '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @t = Thread.new { + @server.start + } + end + + def setup_client + @client = SOAP::RPC::Driver.new(@endpoint, PortName) + @client.wiredump_dev = STDERR if $DEBUG + @client.add_method('ping') + end + + def teardown + teardown_server + teardown_client + end + + def teardown_server + @server.shutdown + @t.kill + @t.join + end + + def teardown_client + @client.reset_stream + end + + def test_string + h = PingClientHeaderHandler.new('pingheader') + @client.headerhandler << h + assert_equal("pingheader", @client.ping) + assert_equal("dummy", Thread.current[:pingheader]) + end +end + + +end +end diff --git a/test/soap/ssl/test_ssl.rb b/test/soap/ssl/test_ssl.rb index d6df97016..38f859acd 100644 --- a/test/soap/ssl/test_ssl.rb +++ b/test/soap/ssl/test_ssl.rb @@ -179,14 +179,14 @@ __EOP__ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "ca.cert") cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "subca.cert") #cfg.timeout = 123 - assert_equal("Hello World, from ssl client", @client.hello_world("ssl client")) - # cfg["protocol.http.ssl_config.ciphers"] = "!ALL" + # begin @client.hello_world("ssl client") assert(false) rescue OpenSSL::SSL::SSLError => ssle - assert_equal("no ciphers available", ssle.message) + # depends on OpenSSL version. (?:0.9.8|0.9.7) + assert_match(/\A(?:SSL_CTX_set_cipher_list:: no cipher match|no ciphers available)\z/, ssle.message) end # cfg["protocol.http.ssl_config.ciphers"] = "ALL" @@ -201,7 +201,7 @@ private def setup_server svrcmd = "#{q(RUBY)} " - svrcmd << "-d " if $DEBUG + #svrcmd << "-d " if $DEBUG svrcmd << File.join(DIR, "sslsvr.rb") svrout = IO.popen(svrcmd) @serverpid = Integer(svrout.gets.chomp) diff --git a/test/soap/swa/test_file.rb b/test/soap/swa/test_file.rb index 8389d8826..1ec7aa92a 100644 --- a/test/soap/swa/test_file.rb +++ b/test/soap/swa/test_file.rb @@ -47,11 +47,14 @@ class TestFile < Test::Unit::TestCase @client.reset_stream end - def test_file + def test_get_file assert_equal( File.open(THIS_FILE) { |f| f.read }, @client.get_file['file'].content ) + end + + def test_put_file assert_equal( "File 'foo' was received ok.", @client.put_file('foo', diff --git a/test/soap/test_envelopenamespace.rb b/test/soap/test_envelopenamespace.rb new file mode 100644 index 000000000..5b7d28134 --- /dev/null +++ b/test/soap/test_envelopenamespace.rb @@ -0,0 +1,92 @@ +require 'test/unit' +require 'soap/rpc/driver' +require 'webrick' +require 'logger' + + +module SOAP + + +class TestEnvelopeNamespace < Test::Unit::TestCase + Port = 17171 + TemporaryNamespace = 'urn:foo' + + def setup + @logger = Logger.new(STDERR) + @logger.level = Logger::Severity::ERROR + @url = "http://localhost:#{Port}/" + @server = @client = nil + @server_thread = nil + setup_server + setup_client + end + + def teardown + teardown_client + teardown_server + end + + def setup_server + @server = WEBrick::HTTPServer.new( + :BindAddress => "0.0.0.0", + :Logger => @logger, + :Port => Port, + :AccessLog => [], + :DocumentRoot => File.dirname(File.expand_path(__FILE__)) + ) + @server.mount( + '/', + WEBrick::HTTPServlet::ProcHandler.new(method(:do_server_proc).to_proc) + ) + @server_thread = start_server_thread(@server) + end + + def setup_client + @client = SOAP::RPC::Driver.new(@url, '') + @client.add_method("do_server_proc") + end + + def teardown_server + @server.shutdown + @server_thread.kill + @server_thread.join + end + + def teardown_client + @client.reset_stream + end + + def start_server_thread(server) + t = Thread.new { + Thread.current.abort_on_exception = true + server.start + } + t + end + + def do_server_proc(req, res) + res['content-type'] = 'text/xml' + res.body = <<__EOX__ +<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:env="#{TemporaryNamespace}"> + <env:Body> + <n1:do_server_proc xmlns:n1="urn:foo" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> + <return>hello world</return> + </n1:do_server_proc> + </env:Body> +</env:Envelope> +__EOX__ + end + + def test_normal + assert_raise(SOAP::ResponseFormatError) do + @client.do_server_proc + end + @client.options["soap.envelope.requestnamespace"] = TemporaryNamespace + @client.options["soap.envelope.responsenamespace"] = TemporaryNamespace + assert_equal('hello world', @client.do_server_proc) + end +end + + +end diff --git a/test/soap/test_httpconfigloader.rb b/test/soap/test_httpconfigloader.rb new file mode 100644 index 000000000..b06243f66 --- /dev/null +++ b/test/soap/test_httpconfigloader.rb @@ -0,0 +1,39 @@ +require 'test/unit' +require 'soap/httpconfigloader' +require 'soap/rpc/driver' + +if defined?(HTTPAccess2) + +module SOAP + + +class TestHTTPConfigLoader < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + + def setup + @client = SOAP::RPC::Driver.new(nil, nil) + end + + def test_property + testpropertyname = File.join(DIR, 'soapclient.properties') + File.open(testpropertyname, "w") do |f| + f <<<<__EOP__ +protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER +# depth: 1 causes an error (intentional) +protocol.http.ssl_config.verify_depth = 1 +protocol.http.ssl_config.ciphers = ALL +__EOP__ + end + begin + @client.loadproperty(testpropertyname) + assert_equal('ALL', @client.options['protocol.http.ssl_config.ciphers']) + ensure + File.unlink(testpropertyname) + end + end +end + + +end + +end diff --git a/test/soap/test_no_indent.rb b/test/soap/test_no_indent.rb new file mode 100644 index 000000000..f49fb7389 --- /dev/null +++ b/test/soap/test_no_indent.rb @@ -0,0 +1,86 @@ +require 'test/unit' +require 'soap/rpc/standaloneServer' +require 'soap/rpc/driver' + +if defined?(HTTPAccess2) + +module SOAP + + +class TestNoIndent < Test::Unit::TestCase + Port = 17171 + + class NopServer < SOAP::RPC::StandaloneServer + def initialize(*arg) + super + add_rpc_method(self, 'nop') + end + + def nop + SOAP::RPC::SOAPVoid.new + end + end + + def setup + @server = NopServer.new(self.class.name, nil, '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @t = Thread.new { + @server.start + } + @endpoint = "http://localhost:#{Port}/" + @client = SOAP::RPC::Driver.new(@endpoint) + @client.add_rpc_method('nop') + end + + def teardown + @server.shutdown + @t.kill + @t.join + @client.reset_stream + end + + INDENT_XML = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> + </nop> + </env:Body> +</env:Envelope>] + + NO_INDENT_XML = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" +xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<env:Body> +<nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> +</nop> +</env:Body> +</env:Envelope>] + + def test_indent + @client.wiredump_dev = str = '' + @client.options["soap.envelope.no_indent"] = false + @client.nop + assert_equal(INDENT_XML, parse_requestxml(str)) + end + + def test_no_indent + @client.wiredump_dev = str = '' + @client.options["soap.envelope.no_indent"] = true + @client.nop + assert_equal(NO_INDENT_XML, parse_requestxml(str)) + end + + def parse_requestxml(str) + str.split(/\r?\n\r?\n/)[3] + end +end + + +end + +end diff --git a/test/soap/test_soapelement.rb b/test/soap/test_soapelement.rb index 6cf91f93d..66e2a836a 100644 --- a/test/soap/test_soapelement.rb +++ b/test/soap/test_soapelement.rb @@ -1,5 +1,6 @@ require 'test/unit' require 'soap/baseData' +require 'soap/mapping' module SOAP @@ -36,7 +37,7 @@ class TestSOAPElement < Test::Unit::TestCase assert_equal(LiteralNamespace, obj.encodingstyle) assert_equal({}, obj.extraattr) assert_equal([], obj.precedents) - assert_equal(false, obj.qualified) + assert_equal(nil, obj.qualified) assert_equal(nil, obj.text) assert(obj.members.empty?) diff --git a/test/soap/test_streamhandler.rb b/test/soap/test_streamhandler.rb index a8d06d5f2..c31254513 100644 --- a/test/soap/test_streamhandler.rb +++ b/test/soap/test_streamhandler.rb @@ -98,7 +98,7 @@ __EOX__ end def parse_req_header(str) - if ::SOAP::StreamHandler::Client.to_s == 'SOAP::NetHttpClient' + if ::SOAP::HTTPStreamHandler::Client.to_s == 'SOAP::NetHttpClient' str = eval(str.split(/\r?\n/)[4][3..-1]) end parse_req_header_http_access2(str) diff --git a/test/wsdl/any/any.wsdl b/test/wsdl/any/any.wsdl new file mode 100644 index 000000000..4d1f73a8c --- /dev/null +++ b/test/wsdl/any/any.wsdl @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<definitions name="echo" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="urn:example.com:echo" + xmlns:txd="urn:example.com:echo-type" + targetNamespace="urn:example.com:echo" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + <types> + <xsd:schema targetNamespace="urn:example.com:echo-type"> + <xsd:complexType name="foo.bar"> + <xsd:sequence> + <xsd:any /> + </xsd:sequence> + </xsd:complexType> + </xsd:schema> + </types> + + <message name="msg_echoitem"> + <part name="echoitem" type="txd:foo.bar"/> + </message> + + <portType name="echo_port_type"> + <operation name="echo"> + <input message="tns:msg_echoitem"/> + <output message="tns:msg_echoitem"/> + </operation> + </portType> + + <binding name="echo_binding" type="tns:echo_port_type"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> + <operation name="echo"> + <soap:operation soapAction="urn:example.com:echo"/> + <input> + <soap:body use="encoded" namespace="urn:example.com:echo" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </input> + <output> + <soap:body use="encoded" namespace="urn:example.com:echo" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </output> + </operation> + </binding> + + <service name="echo_service"> + <port name="echo_port" binding="tns:echo_binding"> + <soap:address location="http://localhost:10080"/> + </port> + </service> +</definitions> diff --git a/test/wsdl/any/expectedDriver.rb b/test/wsdl/any/expectedDriver.rb new file mode 100644 index 000000000..6d1827fb9 --- /dev/null +++ b/test/wsdl/any/expectedDriver.rb @@ -0,0 +1,54 @@ +require 'echo.rb' + +require 'soap/rpc/driver' + +class Echo_port_type < ::SOAP::RPC::Driver + DefaultEndpointUrl = "http://localhost:10080" + MappingRegistry = ::SOAP::Mapping::Registry.new + + MappingRegistry.set( + FooBar, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("urn:example.com:echo-type", "foo.bar") } + ) + + Methods = [ + [ XSD::QName.new("urn:example.com:echo", "echo"), + "urn:example.com:echo", + "echo", + [ ["in", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]], + ["retval", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ] + ] + + def initialize(endpoint_url = nil) + endpoint_url ||= DefaultEndpointUrl + super(endpoint_url, nil) + self.mapping_registry = MappingRegistry + init_methods + end + +private + + def init_methods + Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + add_document_operation(*definitions) + else + add_rpc_operation(*definitions) + qname = definitions[0] + name = definitions[2] + if qname.name != name and qname.name.capitalize == name.capitalize + ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg| + __send__(name, *arg) + end + end + end + end + end +end + diff --git a/test/wsdl/any/expectedEcho.rb b/test/wsdl/any/expectedEcho.rb new file mode 100644 index 000000000..456950dfe --- /dev/null +++ b/test/wsdl/any/expectedEcho.rb @@ -0,0 +1,14 @@ +require 'xsd/qname' + +# {urn:example.com:echo-type}foo.bar +class FooBar + @@schema_type = "foo.bar" + @@schema_ns = "urn:example.com:echo-type" + @@schema_element = [["any", [nil, XSD::QName.new(nil, "any")]]] + + attr_accessor :any + + def initialize(any = nil) + @any = any + end +end diff --git a/test/wsdl/any/expectedService.rb b/test/wsdl/any/expectedService.rb new file mode 100644 index 000000000..e3885e7c6 --- /dev/null +++ b/test/wsdl/any/expectedService.rb @@ -0,0 +1,52 @@ +#!/usr/bin/env ruby +require 'echoServant.rb' + +require 'soap/rpc/standaloneServer' +require 'soap/mapping/registry' + +class Echo_port_type + MappingRegistry = ::SOAP::Mapping::Registry.new + + MappingRegistry.set( + FooBar, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("urn:example.com:echo-type", "foo.bar") } + ) + + Methods = [ + [ XSD::QName.new("urn:example.com:echo", "echo"), + "urn:example.com:echo", + "echo", + [ ["in", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]], + ["retval", "echoitem", ["FooBar", "urn:example.com:echo-type", "foo.bar"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ] + ] +end + +class Echo_port_typeApp < ::SOAP::RPC::StandaloneServer + def initialize(*arg) + super(*arg) + servant = Echo_port_type.new + Echo_port_type::Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + @router.add_document_operation(servant, *definitions) + else + @router.add_rpc_operation(servant, *definitions) + end + end + self.mapping_registry = Echo_port_type::MappingRegistry + end +end + +if $0 == __FILE__ + # Change listen port. + server = Echo_port_typeApp.new('app', nil, '0.0.0.0', 10080) + trap(:INT) do + server.shutdown + end + server.start +end diff --git a/test/wsdl/any/test_any.rb b/test/wsdl/any/test_any.rb new file mode 100644 index 000000000..7b0e480be --- /dev/null +++ b/test/wsdl/any/test_any.rb @@ -0,0 +1,46 @@ +require 'test/unit' +require 'wsdl/parser' +require 'wsdl/soap/wsdl2ruby' +module WSDL; module Any + + +class TestAny < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + def pathname(filename) + File.join(DIR, filename) + end + + def test_any + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("any.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['driver'] = nil + gen.opt['client_skelton'] = nil + gen.opt['servant_skelton'] = nil + gen.opt['standalone_server_stub'] = nil + gen.opt['force'] = true + gen.run + compare("expectedDriver.rb", "echoDriver.rb") + compare("expectedEcho.rb", "echo.rb") + compare("expectedService.rb", "echo_service.rb") + + File.unlink(pathname("echo_service.rb")) + File.unlink(pathname("echo.rb")) + File.unlink(pathname("echo_serviceClient.rb")) + File.unlink(pathname("echoDriver.rb")) + File.unlink(pathname("echoServant.rb")) + end + + def compare(expected, actual) + assert_equal(loadfile(expected), loadfile(actual), actual) + end + + def loadfile(file) + File.open(pathname(file)) { |f| f.read } + end +end + + +end; end diff --git a/test/wsdl/document/echo.rb b/test/wsdl/document/echo.rb index 05f00412f..c6df75aca 100644 --- a/test/wsdl/document/echo.rb +++ b/test/wsdl/document/echo.rb @@ -5,7 +5,7 @@ class Echoele @@schema_type = "echoele" @@schema_ns = "urn:docrpc" @@schema_attribute = {XSD::QName.new(nil, "attr_string") => "SOAP::SOAPString", XSD::QName.new(nil, "attr-int") => "SOAP::SOAPInt"} - @@schema_element = [["struct1", "Echo_struct"], ["struct_2", ["Echo_struct", XSD::QName.new(nil, "struct-2")]]] + @@schema_element = [["struct1", ["Echo_struct", XSD::QName.new(nil, "struct1")]], ["struct_2", ["Echo_struct", XSD::QName.new(nil, "struct-2")]]] attr_accessor :struct1 attr_accessor :struct_2 @@ -38,7 +38,7 @@ class Echo_response @@schema_type = "echo_response" @@schema_ns = "urn:docrpc" @@schema_attribute = {XSD::QName.new(nil, "attr_string") => "SOAP::SOAPString", XSD::QName.new(nil, "attr-int") => "SOAP::SOAPInt"} - @@schema_element = [["struct1", "Echo_struct"], ["struct_2", ["Echo_struct", XSD::QName.new(nil, "struct-2")]]] + @@schema_element = [["struct1", ["Echo_struct", XSD::QName.new(nil, "struct1")]], ["struct_2", ["Echo_struct", XSD::QName.new(nil, "struct-2")]]] attr_accessor :struct1 attr_accessor :struct_2 @@ -70,18 +70,18 @@ end class Echo_struct @@schema_type = "echo_struct" @@schema_ns = "urn:docrpc" - @@schema_attribute = {XSD::QName.new("urn:docrpc", "m_attr") => "SOAP::SOAPString"} - @@schema_element = [["m_string", "SOAP::SOAPString"], ["m_datetime", "SOAP::SOAPDateTime"]] + @@schema_attribute = {XSD::QName.new(nil, "m_attr") => "SOAP::SOAPString"} + @@schema_element = [["m_string", ["SOAP::SOAPString", XSD::QName.new(nil, "m_string")]], ["m_datetime", ["SOAP::SOAPDateTime", XSD::QName.new(nil, "m_datetime")]]] attr_accessor :m_string attr_accessor :m_datetime def xmlattr_m_attr - (@__xmlattr ||= {})[XSD::QName.new("urn:docrpc", "m_attr")] + (@__xmlattr ||= {})[XSD::QName.new(nil, "m_attr")] end def xmlattr_m_attr=(value) - (@__xmlattr ||= {})[XSD::QName.new("urn:docrpc", "m_attr")] = value + (@__xmlattr ||= {})[XSD::QName.new(nil, "m_attr")] = value end def initialize(m_string = nil, m_datetime = nil) diff --git a/test/wsdl/marshal/person_org.rb b/test/wsdl/marshal/person_org.rb index 55405b658..f8c0e0db7 100644 --- a/test/wsdl/marshal/person_org.rb +++ b/test/wsdl/marshal/person_org.rb @@ -4,7 +4,7 @@ require 'xsd/qname' class Person @@schema_type = "Person" @@schema_ns = "http://www.jin.gr.jp/~nahi/xmlns/sample/Person" - @@schema_element = [["familyname", "SOAP::SOAPString"], ["givenname", "SOAP::SOAPString"], ["var1", "SOAP::SOAPInt"], ["var2", "SOAP::SOAPDouble"], ["var3", "SOAP::SOAPString"]] + @@schema_element = [["familyname", ["SOAP::SOAPString", XSD::QName.new(nil, "familyname")]], ["givenname", ["SOAP::SOAPString", XSD::QName.new(nil, "givenname")]], ["var1", ["SOAP::SOAPInt", XSD::QName.new(nil, "var1")]], ["var2", ["SOAP::SOAPDouble", XSD::QName.new(nil, "var2")]], ["var3", ["SOAP::SOAPString", XSD::QName.new(nil, "var3")]]] attr_accessor :familyname attr_accessor :givenname diff --git a/test/wsdl/qualified/lp.wsdl b/test/wsdl/qualified/lp.wsdl new file mode 100644 index 000000000..b107b7b39 --- /dev/null +++ b/test/wsdl/qualified/lp.wsdl @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="utf-8"?> +<definitions + name="lp" + targetNamespace="urn:lp" + xmlns:tns="urn:lp" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + <types> + <schema xmlns="http://www.w3.org/2001/XMLSchema"> + <import namespace="urn:lp" schemaLocation="lp.xsd"/> + </schema> + </types> + + <message name="login_in"> + <part name="parameters" element="tns:login" /> + </message> + <message name="login_out"> + <part name="parameters" element="tns:loginResponse" /> + </message> + + <portType name="lp_porttype"> + <operation name="login"> + <input message="tns:login_in" /> + <output message="tns:login_out" /> + </operation> + </portType> + + <binding name="lp_binding" type="tns:lp_porttype"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> + <operation name="login"> + <soap:operation soapAction="urn:lp:login" style="document" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + </binding> + + <service name="lp_service"> + <port name="lp_service_port" binding="tns:lp_binding"> + <soap:address location="http://localhost:17171/" /> + </port> + </service> +</definitions> diff --git a/test/wsdl/qualified/lp.xsd b/test/wsdl/qualified/lp.xsd new file mode 100644 index 000000000..12bcbd8ce --- /dev/null +++ b/test/wsdl/qualified/lp.xsd @@ -0,0 +1,26 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:lp="urn:lp" targetNamespace="urn:lp" elementFormDefault="unqualified"> + + <xs:complexType name="login"> + <xs:sequence> + <xs:element name="username" type="xs:string"/> + <xs:element name="password" type="xs:string"/> + <xs:element name="timezone" type="xs:string" minOccurs="0" maxOccurs="1"/> + </xs:sequence> + </xs:complexType> + + <xs:element name="login" type="lp:login"/> + + <xs:complexType name="loginResponse"> + <xs:sequence> + <xs:element name="loginResult"> + <xs:complexType> + <xs:sequence> + <xs:element name="sessionID" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + + <xs:element name="loginResponse" type="lp:loginResponse"/> +</xs:schema> diff --git a/test/wsdl/qualified/np.wsdl b/test/wsdl/qualified/np.wsdl new file mode 100644 index 000000000..e2b7253d0 --- /dev/null +++ b/test/wsdl/qualified/np.wsdl @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www50.brinkster.com/vbfacileinpt/np" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www50.brinkster.com/vbfacileinpt/np" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> + <wsdl:types> + <s:schema elementFormDefault="qualified" targetNamespace="http://www50.brinkster.com/vbfacileinpt/np"> + <s:element name="GetPrimeNumbers"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="Max" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + <s:element name="GetPrimeNumbersResponse"> + <s:complexType> + <s:sequence> + <s:element minOccurs="0" maxOccurs="1" name="GetPrimeNumbersResult" type="s:string" /> + </s:sequence> + </s:complexType> + </s:element> + </s:schema> + </wsdl:types> + <wsdl:message name="GetPrimeNumbersSoapIn"> + <wsdl:part name="parameters" element="tns:GetPrimeNumbers" /> + </wsdl:message> + <wsdl:message name="GetPrimeNumbersSoapOut"> + <wsdl:part name="parameters" element="tns:GetPrimeNumbersResponse" /> + </wsdl:message> + <wsdl:portType name="pnumSoap"> + <wsdl:operation name="GetPrimeNumbers"> + <wsdl:input message="tns:GetPrimeNumbersSoapIn" /> + <wsdl:output message="tns:GetPrimeNumbersSoapOut" /> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="pnumSoap" type="tns:pnumSoap"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> + <wsdl:operation name="GetPrimeNumbers"> + <soap:operation soapAction="http://www50.brinkster.com/vbfacileinpt/np/GetPrimeNumbers" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="pnum"> + <wsdl:port name="pnumSoap" binding="tns:pnumSoap"> + <soap:address location="http://www50.brinkster.com/vbfacileinpt/np.asmx" /> + </wsdl:port> + </wsdl:service> +</wsdl:definitions>
\ No newline at end of file diff --git a/test/wsdl/qualified/test_qualified.rb b/test/wsdl/qualified/test_qualified.rb new file mode 100644 index 000000000..d6c1159a8 --- /dev/null +++ b/test/wsdl/qualified/test_qualified.rb @@ -0,0 +1,154 @@ +require 'test/unit' +require 'wsdl/soap/wsdl2ruby' +require 'soap/rpc/standaloneServer' +require 'soap/wsdlDriver' + +if defined?(HTTPAccess2) + +module WSDL + + +class TestQualified < Test::Unit::TestCase + class Server < ::SOAP::RPC::StandaloneServer + Namespace = 'http://www50.brinkster.com/vbfacileinpt/np' + + def on_init + add_document_method( + self, + Namespace + '/GetPrimeNumbers', + 'GetPrimeNumbers', + XSD::QName.new(Namespace, 'GetPrimeNumbers'), + XSD::QName.new(Namespace, 'GetPrimeNumbersResponse') + ) + end + + def GetPrimeNumbers(arg) + nil + end + end + + DIR = File.dirname(File.expand_path(__FILE__)) + Port = 17171 + + def setup + setup_server + setup_clientdef + @client = nil + end + + def teardown + teardown_server + unless $DEBUG + File.unlink(pathname('default.rb')) + File.unlink(pathname('defaultDriver.rb')) + end + @client.reset_stream if @client + end + + def setup_server + @server = Server.new('Test', "urn:lp", '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @server_thread = start_server_thread(@server) + end + + def setup_clientdef + backupdir = Dir.pwd + begin + Dir.chdir(DIR) + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("np.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['driver'] = nil + gen.opt['force'] = true + gen.run + require pathname('default.rb') + ensure + Dir.chdir(backupdir) + end + end + + def teardown_server + @server.shutdown + @server_thread.kill + @server_thread.join + end + + def start_server_thread(server) + t = Thread.new { + Thread.current.abort_on_exception = true + server.start + } + t + end + + def pathname(filename) + File.join(DIR, filename) + end + + LOGIN_REQUEST_QUALIFIED_NS = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:GetPrimeNumbers xmlns:n1="http://www50.brinkster.com/vbfacileinpt/np"> + <n1:Max>10</n1:Max> + </n1:GetPrimeNumbers> + </env:Body> +</env:Envelope>] + + LOGIN_REQUEST_QUALIFIED = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <GetPrimeNumbers xmlns="http://www50.brinkster.com/vbfacileinpt/np"> + <Max>10</Max> + </GetPrimeNumbers> + </env:Body> +</env:Envelope>] + + def test_wsdl + wsdl = File.join(DIR, 'np.wsdl') + @client = nil + backupdir = Dir.pwd + begin + Dir.chdir(DIR) + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver + ensure + Dir.chdir(backupdir) + end + @client.endpoint_url = "http://localhost:#{Port}/" + @client.wiredump_dev = str = '' + @client.GetPrimeNumbers(:Max => 10) + assert_equal(LOGIN_REQUEST_QUALIFIED_NS, parse_requestxml(str)) + end + + include ::SOAP + def test_naive + backupdir = Dir.pwd + begin + Dir.chdir(DIR) + require pathname('defaultDriver') + ensure + Dir.chdir(backupdir) + end + @client = PnumSoap.new("http://localhost:#{Port}/") + + @client.wiredump_dev = str = '' + @client.getPrimeNumbers(GetPrimeNumbers.new(10)) + assert_equal(LOGIN_REQUEST_QUALIFIED, parse_requestxml(str)) + end + + def parse_requestxml(str) + str.split(/\r?\n\r?\n/)[3] + end +end + + +end + +end diff --git a/test/wsdl/qualified/test_unqualified.rb b/test/wsdl/qualified/test_unqualified.rb new file mode 100644 index 000000000..bcfed73e5 --- /dev/null +++ b/test/wsdl/qualified/test_unqualified.rb @@ -0,0 +1,143 @@ +require 'test/unit' +require 'wsdl/soap/wsdl2ruby' +require 'soap/rpc/standaloneServer' +require 'soap/wsdlDriver' + +if defined?(HTTPAccess2) + +module WSDL + + +class TestUnqualified < Test::Unit::TestCase + class Server < ::SOAP::RPC::StandaloneServer + Namespace = 'urn:lp' + + def on_init + add_document_method( + self, + Namespace + ':login', + 'login', + XSD::QName.new(Namespace, 'login'), + XSD::QName.new(Namespace, 'loginResponse') + ) + end + + def login(arg) + nil + end + end + + DIR = File.dirname(File.expand_path(__FILE__)) + Port = 17171 + + def setup + setup_server + setup_clientdef + @client = nil + end + + def teardown + teardown_server + File.unlink(pathname('lp.rb')) + File.unlink(pathname('lpDriver.rb')) + @client.reset_stream if @client + end + + def setup_server + @server = Server.new('Test', "urn:lp", '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @server_thread = start_server_thread(@server) + end + + def setup_clientdef + backupdir = Dir.pwd + begin + Dir.chdir(DIR) + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("lp.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['driver'] = nil + gen.opt['force'] = true + gen.run + require pathname('lp') + ensure + Dir.chdir(backupdir) + end + end + + def teardown_server + @server.shutdown + @server_thread.kill + @server_thread.join + end + + def start_server_thread(server) + t = Thread.new { + Thread.current.abort_on_exception = true + server.start + } + t + end + + def pathname(filename) + File.join(DIR, filename) + end + + LOGIN_REQUEST_QUALIFIED = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:login xmlns:n1="urn:lp"> + <username>NaHi</username> + <password>passwd</password> + <timezone>JST</timezone> + </n1:login> + </env:Body> +</env:Envelope>] + + def test_wsdl + wsdl = File.join(DIR, 'lp.wsdl') + @client = nil + backupdir = Dir.pwd + begin + Dir.chdir(DIR) + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver + ensure + Dir.chdir(backupdir) + end + @client.endpoint_url = "http://localhost:#{Port}/" + @client.wiredump_dev = str = '' + @client.login(:timezone => 'JST', :password => 'passwd', + :username => 'NaHi') + assert_equal(LOGIN_REQUEST_QUALIFIED, parse_requestxml(str)) + end + + include ::SOAP + def test_naive + backupdir = Dir.pwd + begin + Dir.chdir(DIR) + require pathname('lpDriver') + ensure + Dir.chdir(backupdir) + end + @client = Lp_porttype.new("http://localhost:#{Port}/") + + @client.wiredump_dev = str = '' + @client.login(Login.new('NaHi', 'passwd', 'JST')) + assert_equal(LOGIN_REQUEST_QUALIFIED, parse_requestxml(str)) + end + + def parse_requestxml(str) + str.split(/\r?\n\r?\n/)[3] + end +end + + +end + +end diff --git a/test/wsdl/ref/expectedProduct.rb b/test/wsdl/ref/expectedProduct.rb new file mode 100644 index 000000000..91c6e4c56 --- /dev/null +++ b/test/wsdl/ref/expectedProduct.rb @@ -0,0 +1,90 @@ +require 'xsd/qname' + +# {urn:product}Rating +module Rating + C_0 = "0" + C_1 = "+1" + C_1_2 = "-1" +end + +# {urn:product}Product-Bag +class ProductBag + @@schema_type = "Product-Bag" + @@schema_ns = "urn:product" + @@schema_attribute = {XSD::QName.new("urn:product", "version") => "SOAP::SOAPString", XSD::QName.new("urn:product", "yesno") => "SOAP::SOAPString"} + @@schema_element = [["bag", ["Product[]", XSD::QName.new(nil, "bag")]], ["rating", ["SOAP::SOAPString[]", XSD::QName.new("urn:product", "Rating")]], ["product_Bag", [nil, XSD::QName.new("urn:product", "Product-Bag")]], ["comment_1", [nil, XSD::QName.new(nil, "comment_1")]], ["comment_2", ["Comment[]", XSD::QName.new(nil, "comment-2")]]] + + attr_accessor :bag + attr_accessor :product_Bag + attr_accessor :comment_1 + attr_accessor :comment_2 + + def Rating + @rating + end + + def Rating=(value) + @rating = value + end + + def xmlattr_version + (@__xmlattr ||= {})[XSD::QName.new("urn:product", "version")] + end + + def xmlattr_version=(value) + (@__xmlattr ||= {})[XSD::QName.new("urn:product", "version")] = value + end + + def xmlattr_yesno + (@__xmlattr ||= {})[XSD::QName.new("urn:product", "yesno")] + end + + def xmlattr_yesno=(value) + (@__xmlattr ||= {})[XSD::QName.new("urn:product", "yesno")] = value + end + + def initialize(bag = [], rating = [], product_Bag = nil, comment_1 = [], comment_2 = []) + @bag = bag + @rating = rating + @product_Bag = product_Bag + @comment_1 = comment_1 + @comment_2 = comment_2 + @__xmlattr = {} + end +end + +# {urn:product}Creator +class Creator + @@schema_type = "Creator" + @@schema_ns = "urn:product" + @@schema_element = [] + + def initialize + end +end + +# {urn:product}Product +class Product + @@schema_type = "Product" + @@schema_ns = "urn:product" + @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]], ["rating", ["SOAP::SOAPString", XSD::QName.new("urn:product", "Rating")]]] + + attr_accessor :name + + def Rating + @rating + end + + def Rating=(value) + @rating = value + end + + def initialize(name = nil, rating = nil) + @name = name + @rating = rating + end +end + +# {urn:product}Comment +class Comment < String +end diff --git a/test/wsdl/ref/product.wsdl b/test/wsdl/ref/product.wsdl new file mode 100644 index 000000000..993fe217a --- /dev/null +++ b/test/wsdl/ref/product.wsdl @@ -0,0 +1,86 @@ +<?xml version="1.0"?> +<definitions name="product" + targetNamespace="urn:product" + xmlns:tns="urn:product" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + <types> + <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="urn:product"> + <simpleType name="non-empty-string"> + <restriction base="xsd:string"> + <minLength value="1"/> + </restriction> + </simpleType> + + <complexType name="Product"> + <all> + <element name="name" type="xsd:string"/> + <element ref="tns:Rating"/> + </all> + </complexType> + + <complexType name="Comment"> + <simpleContent> + <extension base="xsd:string"> + <attribute name="msgid" type="xsd:string" use="required"/> + </extension> + </simpleContent> + </complexType> + + <attribute name="version" type="tns:non-empty-string"/> + + <attribute default="Y" name="yesno"> + <simpleType> + <restriction base="xsd:string"> + <enumeration value="Y"/> + <enumeration value="N"/> + </restriction> + </simpleType> + </attribute> + + <element name="Rating"> + <simpleType> + <restriction base="xsd:string"> + <enumeration value="+1"/> + <enumeration value="0"/> + <enumeration value="-1"/> + </restriction> + </simpleType> + </element> + + <element name="Product-Bag"> + <complexType> + <sequence> + <element name="bag" type="tns:Product" minOccurs="0" maxOccurs="unbounded"/> + <element ref="tns:Rating" minOccurs="0" maxOccurs="unbounded"/> + <element ref="tns:Product-Bag"/> + <element name="comment_1" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="xsd:string"> + <attribute name="msgid" type="xsd:string" use="required"/> + </extension> + </simpleContent> + </complexType> + </element> + <element name="comment-2" type="tns:Comment" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute ref="tns:version"/> + <attribute ref="tns:yesno"/> + </complexType> + </element> + + <element name="Creator" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="xsd:string"> + <attribute name="Role" type="xs:string" use="required"/> + </extension> + </simpleContent> + </complexType> + </element> + </xsd:schema> + </types> +</definitions> diff --git a/test/wsdl/ref/test_ref.rb b/test/wsdl/ref/test_ref.rb new file mode 100644 index 000000000..165a8643e --- /dev/null +++ b/test/wsdl/ref/test_ref.rb @@ -0,0 +1,42 @@ +require 'test/unit' +require 'soap/rpc/standaloneServer' +require 'soap/wsdlDriver' +require 'wsdl/soap/wsdl2ruby' + + +module WSDL +module Ref + + +class TestRef < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + Port = 17171 + + def test_classdef + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("product.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['force'] = true + gen.run + compare("expectedProduct.rb", "product.rb") + File.unlink(pathname('product.rb')) + end + + def compare(expected, actual) + assert_equal(loadfile(expected), loadfile(actual), actual) + end + + def loadfile(file) + File.open(pathname(file)) { |f| f.read } + end + + def pathname(filename) + File.join(DIR, filename) + end +end + + +end +end diff --git a/test/wsdl/rpc/test-rpc-lit.wsdl b/test/wsdl/rpc/test-rpc-lit.wsdl new file mode 100644 index 000000000..72de747e3 --- /dev/null +++ b/test/wsdl/rpc/test-rpc-lit.wsdl @@ -0,0 +1,364 @@ +<?xml version="1.0"?> + +<definitions name="RPC-Literal-TestDefinitions" + targetNamespace="http://whitemesa.net/wsdl/rpc-lit-test" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://whitemesa.net/wsdl/rpc-lit-test" + xmlns:types="http://soapbuilders.org/rpc-lit-test/types" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> + <types> + <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://soapbuilders.org/rpc-lit-test/types"> + + <element name="stringItem" type="xsd:string" /> + <complexType name="ArrayOfstring"> + <sequence> + <element ref="types:stringItem" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="ArrayOfstringInline"> + <sequence> + <element name="stringItem" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="ArrayOfint"> + <sequence> + <element name="integer" type="xsd:int" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="structItem" type="types:SOAPStruct" /> + <complexType name="SOAPStruct"> + <all> + <element name="varString" type="xsd:string"/> + <element name="varInt" type="xsd:int"/> + <element name="varFloat" type="xsd:float"/> + </all> + </complexType> + + <complexType name="ArrayOfSOAPStruct"> + <sequence> + <element ref="types:structItem" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="SOAPStructStruct"> + <all> + <element name="varString" type="xsd:string"/> + <element name="varInt" type="xsd:int"/> + <element name="varFloat" type="xsd:float"/> + <element ref="types:structItem" /> + </all> + </complexType> + + <complexType name="SOAPArrayStruct"> + <all> + <element name="varString" type="xsd:string"/> + <element name="varInt" type="xsd:int"/> + <element name="varFloat" type="xsd:float"/> + <element name="varArray" type="types:ArrayOfstring"/> + </all> + </complexType> + + </schema> + + </types> + + <!-- echoStruct rpc operation --> + <message name="echoStructRequest"> + <part name="inputStruct" type="types:SOAPStruct"/> + </message> + <message name="echoStructResponse"> + <part name="return" type="types:SOAPStruct"/> + </message> + + <!-- echoStructArray rpc operation --> + <message name="echoStructArrayRequest"> + <part name="inputStructArray" type="types:ArrayOfSOAPStruct"/> + </message> + <message name="echoStructArrayResponse"> + <part name="return" type="types:ArrayOfSOAPStruct"/> + </message> + + <!-- echoStructAsSimpleTypes rpc operation --> + <message name="echoStructAsSimpleTypesRequest"> + <part name="inputStruct" type="types:SOAPStruct"/> + </message> + <message name="echoStructAsSimpleTypesResponse"> + <part name="outputString" type="xsd:string"/> + <part name="outputInteger" type="xsd:int"/> + <part name="outputFloat" type="xsd:float"/> + </message> + + <!-- echoSimpleTypesAsStruct rpc operation --> + <message name="echoSimpleTypesAsStructRequest"> + <part name="inputString" type="xsd:string"/> + <part name="inputInteger" type="xsd:int"/> + <part name="inputFloat" type="xsd:float"/> + </message> + <message name="echoSimpleTypesAsStructResponse"> + <part name="return" type="types:SOAPStruct"/> + </message> + + <!-- echoNestedStruct rpc operation --> + <message name="echoNestedStructRequest"> + <part name="inputStruct" type="types:SOAPStructStruct"/> + </message> + <message name="echoNestedStructResponse"> + <part name="return" type="types:SOAPStructStruct"/> + </message> + + <!-- echoNestedArray rpc operation --> + <message name="echoNestedArrayRequest"> + <part name="inputStruct" type="types:SOAPArrayStruct"/> + </message> + <message name="echoNestedArrayResponse"> + <part name="return" type="types:SOAPArrayStruct"/> + </message> + + <!-- echoStringArray rpc operation --> + <message name="echoStringArrayRequest"> + <part name="inputStringArray" type="types:ArrayOfstring"/> + </message> + <message name="echoStringArrayResponse"> + <part name="return" type="types:ArrayOfstring"/> + </message> + + <message name="echoStringArrayInlineRequest"> + <part name="inputStringArray" type="types:ArrayOfstringInline"/> + </message> + <message name="echoStringArrayInlineResponse"> + <part name="return" type="types:ArrayOfstringInline"/> + </message> + + <!-- echoIntegerArray rpc operation --> + <message name="echoIntegerArrayRequest"> + <part name="inputIntegerArray" type="types:ArrayOfint"/> + </message> + <message name="echoIntegerArrayResponse"> + <part name="return" type="types:ArrayOfint"/> + </message> + + <!-- echoBoolean rpc operation --> + <message name="echoBooleanRequest"> + <part name="inputBoolean" type="xsd:boolean"/> + </message> + <message name="echoBooleanResponse"> + <part name="return" type="xsd:boolean"/> + </message> + + <!-- echoString rpc operation --> + <message name="echoStringRequest"> + <part name="inputString" type="xsd:string"/> + </message> + <message name="echoStringResponse"> + <part name="return" type="xsd:string"/> + </message> + + + <portType name="SoapTestPortTypeRpc"> + + <!-- echoStruct rpc operation --> + <operation name="echoStruct" parameterOrder="inputStruct"> + <input message="tns:echoStructRequest"/> + <output message="tns:echoStructResponse"/> + </operation> + + <!-- echoStructArray rpc operation --> + <operation name="echoStructArray" parameterOrder="inputStructArray"> + <input message="tns:echoStructArrayRequest"/> + <output message="tns:echoStructArrayResponse"/> + </operation> + + <!-- echoStructAsSimpleTypes rpc operation --> + <operation name="echoStructAsSimpleTypes" parameterOrder="inputStruct outputString outputInteger outputFloat"> + <input message="tns:echoStructAsSimpleTypesRequest"/> + <output message="tns:echoStructAsSimpleTypesResponse"/> + </operation> + + <!-- echoSimpleTypesAsStruct rpc operation --> + <operation name="echoSimpleTypesAsStruct" parameterOrder="inputString inputInteger inputFloat"> + <input message="tns:echoSimpleTypesAsStructRequest"/> + <output message="tns:echoSimpleTypesAsStructResponse"/> + </operation> + + <!-- echoNestedStruct rpc operation --> + <operation name="echoNestedStruct" parameterOrder="inputStruct"> + <input message="tns:echoNestedStructRequest"/> + <output message="tns:echoNestedStructResponse"/> + </operation> + + <!-- echoNestedArray rpc operation --> + <operation name="echoNestedArray" parameterOrder="inputStruct"> + <input message="tns:echoNestedArrayRequest"/> + <output message="tns:echoNestedArrayResponse"/> + </operation> + + <!-- echoStringArray rpc operation --> + <operation name="echoStringArray" parameterOrder="inputStringArray"> + <input message="tns:echoStringArrayRequest"/> + <output message="tns:echoStringArrayResponse"/> + </operation> + + <operation name="echoStringArrayInline" parameterOrder="inputStringArray"> + <input message="tns:echoStringArrayInlineRequest"/> + <output message="tns:echoStringArrayInlineResponse"/> + </operation> + + <!-- echoIntegerArray rpc operation --> + <operation name="echoIntegerArray" parameterOrder="inputIntegerArray"> + <input message="tns:echoIntegerArrayRequest"/> + <output message="tns:echoIntegerArrayResponse"/> + </operation> + + <!-- echoBoolean rpc operation --> + <operation name="echoBoolean" parameterOrder="inputBoolean"> + <input message="tns:echoBooleanRequest"/> + <output message="tns:echoBooleanResponse"/> + </operation> + + <!-- echoString rpc operation --> + <operation name="echoString" parameterOrder="inputString"> + <input message="tns:echoStringRequest"/> + <output message="tns:echoStringResponse"/> + </operation> + + </portType> + + <binding name="Soap11TestRpcLitBinding" type="tns:SoapTestPortTypeRpc"> + <soap11:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + + <!-- echoStruct rpc operation --> + <operation name="echoStruct"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStructArray rpc operation --> + <operation name="echoStructArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStructAsSimpleTypes rpc operation --> + <operation name="echoStructAsSimpleTypes"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoSimpleTypesAsStruct rpc operation --> + <operation name="echoSimpleTypesAsStruct"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoNestedStruct rpc operation --> + <operation name="echoNestedStruct"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoNestedArray rpc operation --> + <operation name="echoNestedArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStringArray rpc operation --> + <operation name="echoStringArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <operation name="echoStringArrayInline"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoIntegerArray rpc operation --> + <operation name="echoIntegerArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoBoolean rpc operation --> + <operation name="echoBoolean"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoString rpc operation --> + <operation name="echoString"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + </binding> + + <service name="WhiteMesaSoapRpcLitTestSvc"> + + <port name="Soap11TestRpcLitPort" binding="tns:Soap11TestRpcLitBinding"> + <soap11:address location="http://www.whitemesa.net/test-rpc-lit"/> + </port> + + </service> + +</definitions> diff --git a/test/wsdl/rpc/test-rpc-lit12.wsdl b/test/wsdl/rpc/test-rpc-lit12.wsdl new file mode 100644 index 000000000..901cde6f9 --- /dev/null +++ b/test/wsdl/rpc/test-rpc-lit12.wsdl @@ -0,0 +1,455 @@ +<?xml version="1.0"?> + +<definitions name="RPC-Literal-TestDefinitions" + targetNamespace="http://whitemesa.net/wsdl/rpc-lit-test" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" + xmlns:soap11="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://whitemesa.net/wsdl/rpc-lit-test" + xmlns:types="http://soapbuilders.org/rpc-lit-test/types" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> + <types> + <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://soapbuilders.org/rpc-lit-test/types"> + + <element name="stringItem" type="xsd:string" /> + <complexType name="ArrayOfstring"> + <sequence> + <element ref="types:stringItem" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="ArrayOfint"> + <sequence> + <element name="integer" type="xsd:int" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="structItem" type="types:SOAPStruct" /> + <complexType name="SOAPStruct"> + <all> + <element name="varString" type="xsd:string"/> + <element name="varInt" type="xsd:int"/> + <element name="varFloat" type="xsd:float"/> + </all> + </complexType> + + <complexType name="ArrayOfSOAPStruct"> + <sequence> + <element ref="types:structItem" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <complexType name="SOAPStructStruct"> + <all> + <element name="varString" type="xsd:string"/> + <element name="varInt" type="xsd:int"/> + <element name="varFloat" type="xsd:float"/> + <element ref="types:structItem" /> + </all> + </complexType> + + <complexType name="SOAPArrayStruct"> + <all> + <element name="varString" type="xsd:string"/> + <element name="varInt" type="xsd:int"/> + <element name="varFloat" type="xsd:float"/> + <element name="varArray" type="types:ArrayOfstring"/> + </all> + </complexType> + + </schema> + + </types> + + <!-- echoStruct rpc operation --> + <message name="echoStructRequest"> + <part name="inputStruct" type="types:SOAPStruct"/> + </message> + <message name="echoStructResponse"> + <part name="return" type="types:SOAPStruct"/> + </message> + + <!-- echoStructArray rpc operation --> + <message name="echoStructArrayRequest"> + <part name="inputStructArray" type="types:ArrayOfSOAPStruct"/> + </message> + <message name="echoStructArrayResponse"> + <part name="return" type="types:ArrayOfSOAPStruct"/> + </message> + + <!-- echoStructAsSimpleTypes rpc operation --> + <message name="echoStructAsSimpleTypesRequest"> + <part name="inputStruct" type="types:SOAPStruct"/> + </message> + <message name="echoStructAsSimpleTypesResponse"> + <part name="outputString" type="xsd:string"/> + <part name="outputInteger" type="xsd:int"/> + <part name="outputFloat" type="xsd:float"/> + </message> + + <!-- echoSimpleTypesAsStruct rpc operation --> + <message name="echoSimpleTypesAsStructRequest"> + <part name="inputString" type="xsd:string"/> + <part name="inputInteger" type="xsd:int"/> + <part name="inputFloat" type="xsd:float"/> + </message> + <message name="echoSimpleTypesAsStructResponse"> + <part name="return" type="types:SOAPStruct"/> + </message> + + <!-- echoNestedStruct rpc operation --> + <message name="echoNestedStructRequest"> + <part name="inputStruct" type="types:SOAPStructStruct"/> + </message> + <message name="echoNestedStructResponse"> + <part name="return" type="types:SOAPStructStruct"/> + </message> + + <!-- echoNestedArray rpc operation --> + <message name="echoNestedArrayRequest"> + <part name="inputStruct" type="types:SOAPArrayStruct"/> + </message> + <message name="echoNestedArrayResponse"> + <part name="return" type="types:SOAPArrayStruct"/> + </message> + + <!-- echoStringArray rpc operation --> + <message name="echoStringArrayRequest"> + <part name="inputStringArray" type="types:ArrayOfstring"/> + </message> + <message name="echoStringArrayResponse"> + <part name="return" type="types:ArrayOfstring"/> + </message> + + <!-- echoIntegerArray rpc operation --> + <message name="echoIntegerArrayRequest"> + <part name="inputIntegerArray" type="types:ArrayOfint"/> + </message> + <message name="echoIntegerArrayResponse"> + <part name="return" type="types:ArrayOfint"/> + </message> + + <!-- echoBoolean rpc operation --> + <message name="echoBooleanRequest"> + <part name="inputBoolean" type="xsd:boolean"/> + </message> + <message name="echoBooleanResponse"> + <part name="return" type="xsd:boolean"/> + </message> + + <!-- echoString rpc operation --> + <message name="echoStringRequest"> + <part name="inputString" type="xsd:string"/> + </message> + <message name="echoStringResponse"> + <part name="return" type="xsd:string"/> + </message> + + + <portType name="SoapTestPortTypeRpc"> + + <!-- echoStruct rpc operation --> + <operation name="echoStruct" parameterOrder="inputStruct"> + <input message="tns:echoStructRequest"/> + <output message="tns:echoStructResponse"/> + </operation> + + <!-- echoStructArray rpc operation --> + <operation name="echoStructArray" parameterOrder="inputStructArray"> + <input message="tns:echoStructArrayRequest"/> + <output message="tns:echoStructArrayResponse"/> + </operation> + + <!-- echoStructAsSimpleTypes rpc operation --> + <operation name="echoStructAsSimpleTypes" parameterOrder="inputStruct outputString outputInteger outputFloat"> + <input message="tns:echoStructAsSimpleTypesRequest"/> + <output message="tns:echoStructAsSimpleTypesResponse"/> + </operation> + + <!-- echoSimpleTypesAsStruct rpc operation --> + <operation name="echoSimpleTypesAsStruct" parameterOrder="inputString inputInteger inputFloat"> + <input message="tns:echoSimpleTypesAsStructRequest"/> + <output message="tns:echoSimpleTypesAsStructResponse"/> + </operation> + + <!-- echoNestedStruct rpc operation --> + <operation name="echoNestedStruct" parameterOrder="inputStruct"> + <input message="tns:echoNestedStructRequest"/> + <output message="tns:echoNestedStructResponse"/> + </operation> + + <!-- echoNestedArray rpc operation --> + <operation name="echoNestedArray" parameterOrder="inputStruct"> + <input message="tns:echoNestedArrayRequest"/> + <output message="tns:echoNestedArrayResponse"/> + </operation> + + <!-- echoStringArray rpc operation --> + <operation name="echoStringArray" parameterOrder="inputStringArray"> + <input message="tns:echoStringArrayRequest"/> + <output message="tns:echoStringArrayResponse"/> + </operation> + + <!-- echoIntegerArray rpc operation --> + <operation name="echoIntegerArray" parameterOrder="inputIntegerArray"> + <input message="tns:echoIntegerArrayRequest"/> + <output message="tns:echoIntegerArrayResponse"/> + </operation> + + <!-- echoBoolean rpc operation --> + <operation name="echoBoolean" parameterOrder="inputBoolean"> + <input message="tns:echoBooleanRequest"/> + <output message="tns:echoBooleanResponse"/> + </operation> + + <!-- echoString rpc operation --> + <operation name="echoString" parameterOrder="inputString"> + <input message="tns:echoStringRequest"/> + <output message="tns:echoStringResponse"/> + </operation> + + </portType> + + <binding name="Soap11TestRpcLitBinding" type="tns:SoapTestPortTypeRpc"> + <soap11:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + + <!-- echoStruct rpc operation --> + <operation name="echoStruct"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStructArray rpc operation --> + <operation name="echoStructArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStructAsSimpleTypes rpc operation --> + <operation name="echoStructAsSimpleTypes"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoSimpleTypesAsStruct rpc operation --> + <operation name="echoSimpleTypesAsStruct"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoNestedStruct rpc operation --> + <operation name="echoNestedStruct"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoNestedArray rpc operation --> + <operation name="echoNestedArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStringArray rpc operation --> + <operation name="echoStringArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoIntegerArray rpc operation --> + <operation name="echoIntegerArray"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoBoolean rpc operation --> + <operation name="echoBoolean"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoString rpc operation --> + <operation name="echoString"> + <soap11:operation soapAction="http://soapinterop.org/"/> + <input> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap11:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + </binding> + + <binding name="Soap12TestRpcLitBinding" type="tns:SoapTestPortTypeRpc"> + <soap12:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + + <!-- echoStruct rpc operation --> + <operation name="echoStruct"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStructArray rpc operation --> + <operation name="echoStructArray"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStructAsSimpleTypes rpc operation --> + <operation name="echoStructAsSimpleTypes"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoSimpleTypesAsStruct rpc operation --> + <operation name="echoSimpleTypesAsStruct"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoNestedStruct rpc operation --> + <operation name="echoNestedStruct"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoNestedArray rpc operation --> + <operation name="echoNestedArray"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoStringArray rpc operation --> + <operation name="echoStringArray"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoIntegerArray rpc operation --> + <operation name="echoIntegerArray"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoBoolean rpc operation --> + <operation name="echoBoolean"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + <!-- echoString rpc operation --> + <operation name="echoString"> + <soap12:operation/> + <input> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </input> + <output> + <soap12:body use="literal" namespace="http://soapbuilders.org/rpc-lit-test" /> + </output> + </operation> + + </binding> + + <service name="WhiteMesaSoapRpcLitTestSvc"> + + <port name="Soap12TestRpcLitPort" binding="tns:Soap12TestRpcLitBinding"> + <soap12:address location="http://www.whitemesa.net/soap12/test-rpc-lit"/> + </port> + <port name="Soap11TestRpcLitPort" binding="tns:Soap11TestRpcLitBinding"> + <soap11:address location="http://www.whitemesa.net/test-rpc-lit"/> + </port> + + </service> + +</definitions> diff --git a/test/wsdl/rpc/test_rpc_lit.rb b/test/wsdl/rpc/test_rpc_lit.rb new file mode 100644 index 000000000..080dbb82c --- /dev/null +++ b/test/wsdl/rpc/test_rpc_lit.rb @@ -0,0 +1,399 @@ +require 'test/unit' +require 'wsdl/soap/wsdl2ruby' +require 'soap/rpc/standaloneServer' +require 'soap/wsdlDriver' + +if defined?(HTTPAccess2) and defined?(OpenSSL) + +module WSDL; module RPC + + +class TestRPCLIT < Test::Unit::TestCase + class Server < ::SOAP::RPC::StandaloneServer + Namespace = "http://soapbuilders.org/rpc-lit-test" + + def on_init + self.generate_explicit_type = false + add_rpc_operation(self, + XSD::QName.new(Namespace, 'echoStringArray'), + nil, + 'echoStringArray', [ + ['in', 'inputStringArray', nil], + ['retval', 'return', nil] + ], + { + :request_style => :rpc, + :request_use => :literal, + :response_style => :rpc, + :response_use => :literal + } + ) + add_rpc_operation(self, + XSD::QName.new(Namespace, 'echoStringArrayInline'), + nil, + 'echoStringArrayInline', [ + ['in', 'inputStringArray', nil], + ['retval', 'return', nil] + ], + { + :request_style => :rpc, + :request_use => :literal, + :response_style => :rpc, + :response_use => :literal + } + ) + add_rpc_operation(self, + XSD::QName.new(Namespace, 'echoNestedStruct'), + nil, + 'echoNestedStruct', [ + ['in', 'inputNestedStruct', nil], + ['retval', 'return', nil] + ], + { + :request_style => :rpc, + :request_use => :literal, + :response_style => :rpc, + :response_use => :literal + } + ) + add_rpc_operation(self, + XSD::QName.new(Namespace, 'echoStructArray'), + nil, + 'echoStructArray', [ + ['in', 'inputStructArray', nil], + ['retval', 'return', nil] + ], + { + :request_style => :rpc, + :request_use => :literal, + :response_style => :rpc, + :response_use => :literal + } + ) + end + + def echoStringArray(strings) + # strings.stringItem => Array + ArrayOfstring[*strings.stringItem] + end + + def echoStringArrayInline(strings) + ArrayOfstringInline[*strings.stringItem] + end + + def echoNestedStruct(struct) + struct + end + + def echoStructArray(ary) + ary + end + end + + DIR = File.dirname(File.expand_path(__FILE__)) + + Port = 17171 + + def setup + setup_server + setup_classdef + @client = nil + end + + def teardown + teardown_server + unless $DEBUG + File.unlink(pathname('RPC-Literal-TestDefinitions.rb')) + File.unlink(pathname('RPC-Literal-TestDefinitionsDriver.rb')) + end + @client.reset_stream if @client + end + + def setup_server + @server = Server.new('Test', Server::Namespace, '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @server_thread = start_server_thread(@server) + end + + def setup_classdef + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("test-rpc-lit.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['driver'] = nil + gen.opt['force'] = true + gen.run + backupdir = Dir.pwd + begin + Dir.chdir(DIR) + require pathname('RPC-Literal-TestDefinitions.rb') + require pathname('RPC-Literal-TestDefinitionsDriver.rb') + ensure + Dir.chdir(backupdir) + end + end + + def teardown_server + @server.shutdown + @server_thread.kill + @server_thread.join + end + + def start_server_thread(server) + t = Thread.new { + Thread.current.abort_on_exception = true + server.start + } + t + end + + def pathname(filename) + File.join(DIR, filename) + end + + def test_wsdl_echoStringArray + wsdl = pathname('test-rpc-lit.wsdl') + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver + @client.endpoint_url = "http://localhost:#{Port}/" + @client.wiredump_dev = STDOUT if $DEBUG + # response contains only 1 part. + result = @client.echoStringArray(ArrayOfstring["a", "b", "c"])[0] + assert_equal(["a", "b", "c"], result.stringItem) + end + + ECHO_STRING_ARRAY_REQUEST = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoStringArray xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <inputStringArray xmlns:n2="http://soapbuilders.org/rpc-lit-test/types"> + <n2:stringItem>a</n2:stringItem> + <n2:stringItem>b</n2:stringItem> + <n2:stringItem>c</n2:stringItem> + </inputStringArray> + </n1:echoStringArray> + </env:Body> +</env:Envelope>] + + ECHO_STRING_ARRAY_RESPONSE = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoStringArrayResponse xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <return xmlns:n2="http://soapbuilders.org/rpc-lit-test/types"> + <n2:stringItem>a</n2:stringItem> + <n2:stringItem>b</n2:stringItem> + <n2:stringItem>c</n2:stringItem> + </return> + </n1:echoStringArrayResponse> + </env:Body> +</env:Envelope>] + + def test_stub_echoStringArray + drv = SoapTestPortTypeRpc.new("http://localhost:#{Port}/") + drv.wiredump_dev = str = '' + # response contains only 1 part. + result = drv.echoStringArray(ArrayOfstring["a", "b", "c"])[0] + assert_equal(["a", "b", "c"], result.stringItem) + assert_equal(ECHO_STRING_ARRAY_REQUEST, parse_requestxml(str)) + assert_equal(ECHO_STRING_ARRAY_RESPONSE, parse_responsexml(str)) + end + + ECHO_STRING_ARRAY_INLINE_REQUEST = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoStringArrayInline xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <inputStringArray> + <stringItem>a</stringItem> + <stringItem>b</stringItem> + <stringItem>c</stringItem> + </inputStringArray> + </n1:echoStringArrayInline> + </env:Body> +</env:Envelope>] + + ECHO_STRING_ARRAY_INLINE_RESPONSE = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoStringArrayInlineResponse xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <return> + <stringItem>a</stringItem> + <stringItem>b</stringItem> + <stringItem>c</stringItem> + </return> + </n1:echoStringArrayInlineResponse> + </env:Body> +</env:Envelope>] + + def test_stub_echoStringArrayInline + drv = SoapTestPortTypeRpc.new("http://localhost:#{Port}/") + drv.wiredump_dev = str = '' + # response contains only 1 part. + result = drv.echoStringArrayInline(ArrayOfstringInline["a", "b", "c"])[0] + assert_equal(["a", "b", "c"], result.stringItem) + assert_equal(ECHO_STRING_ARRAY_INLINE_REQUEST, parse_requestxml(str)) + assert_equal(ECHO_STRING_ARRAY_INLINE_RESPONSE, parse_responsexml(str)) + end + + ECHO_NESTED_STRUCT_REQUEST = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoNestedStruct xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <inputStruct xmlns:n2="http://soapbuilders.org/rpc-lit-test/types"> + <varString>str</varString> + <varInt>1</varInt> + <varFloat>+1</varFloat> + <n2:structItem> + <varString>str</varString> + <varInt>1</varInt> + <varFloat>+1</varFloat> + </n2:structItem> + </inputStruct> + </n1:echoNestedStruct> + </env:Body> +</env:Envelope>] + + ECHO_NESTED_STRUCT_RESPONSE = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoNestedStructResponse xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <return xmlns:n2="http://soapbuilders.org/rpc-lit-test/types"> + <varString>str</varString> + <varInt>1</varInt> + <varFloat>+1</varFloat> + <n2:structItem> + <varString>str</varString> + <varInt>1</varInt> + <varFloat>+1</varFloat> + </n2:structItem> + </return> + </n1:echoNestedStructResponse> + </env:Body> +</env:Envelope>] + + def test_wsdl_echoNestedStruct + wsdl = pathname('test-rpc-lit.wsdl') + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver + @client.endpoint_url = "http://localhost:#{Port}/" + @client.wiredump_dev = str = '' + # response contains only 1 part. + result = @client.echoNestedStruct(SOAPStructStruct.new("str", 1, 1.0, SOAPStruct.new("str", 1, 1.0)))[0] + assert_equal('str', result.varString) + assert_equal('1', result.varInt) + assert_equal('+1', result.varFloat) + assert_equal('str', result.structItem.varString) + assert_equal('1', result.structItem.varInt) + assert_equal('+1', result.structItem.varFloat) + assert_equal(ECHO_NESTED_STRUCT_REQUEST, parse_requestxml(str)) + assert_equal(ECHO_NESTED_STRUCT_RESPONSE, parse_responsexml(str)) + end + + def test_stub_echoNestedStruct + drv = SoapTestPortTypeRpc.new("http://localhost:#{Port}/") + drv.wiredump_dev = str = '' + # response contains only 1 part. + result = drv.echoNestedStruct(SOAPStructStruct.new("str", 1, 1.0, SOAPStruct.new("str", 1, 1.0)))[0] + assert_equal('str', result.varString) + assert_equal('1', result.varInt) + assert_equal('+1', result.varFloat) + assert_equal('str', result.structItem.varString) + assert_equal('1', result.structItem.varInt) + assert_equal('+1', result.structItem.varFloat) + assert_equal(ECHO_NESTED_STRUCT_REQUEST, parse_requestxml(str)) + assert_equal(ECHO_NESTED_STRUCT_RESPONSE, parse_responsexml(str)) + end + + ECHO_STRUCT_ARRAY_REQUEST = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoStructArray xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <inputStructArray xmlns:n2="http://soapbuilders.org/rpc-lit-test/types"> + <n2:structItem> + <varString>str</varString> + <varInt>2</varInt> + <varFloat>+2.1</varFloat> + </n2:structItem> + <n2:structItem> + <varString>str</varString> + <varInt>2</varInt> + <varFloat>+2.1</varFloat> + </n2:structItem> + </inputStructArray> + </n1:echoStructArray> + </env:Body> +</env:Envelope>] + + ECHO_STRUCT_ARRAY_RESPONSE = +%q[<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n1:echoStructArrayResponse xmlns:n1="http://soapbuilders.org/rpc-lit-test"> + <return xmlns:n2="http://soapbuilders.org/rpc-lit-test/types"> + <n2:structItem> + <varString>str</varString> + <varInt>2</varInt> + <varFloat>+2.1</varFloat> + </n2:structItem> + <n2:structItem> + <varString>str</varString> + <varInt>2</varInt> + <varFloat>+2.1</varFloat> + </n2:structItem> + </return> + </n1:echoStructArrayResponse> + </env:Body> +</env:Envelope>] + + def test_wsdl_echoStructArray + wsdl = pathname('test-rpc-lit.wsdl') + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver + @client.endpoint_url = "http://localhost:#{Port}/" + @client.wiredump_dev = str = '' + # response contains only 1 part. + e = SOAPStruct.new("str", 2, 2.1) + result = @client.echoStructArray(ArrayOfSOAPStruct[e, e]) + assert_equal(ECHO_STRUCT_ARRAY_REQUEST, parse_requestxml(str)) + assert_equal(ECHO_STRUCT_ARRAY_RESPONSE, parse_responsexml(str)) + end + + def test_stub_echoStructArray + drv = SoapTestPortTypeRpc.new("http://localhost:#{Port}/") + drv.wiredump_dev = str = '' + # response contains only 1 part. + e = SOAPStruct.new("str", 2, 2.1) + result = drv.echoStructArray(ArrayOfSOAPStruct[e, e]) + assert_equal(ECHO_STRUCT_ARRAY_REQUEST, parse_requestxml(str)) + assert_equal(ECHO_STRUCT_ARRAY_RESPONSE, parse_responsexml(str)) + end + + def parse_requestxml(str) + str.split(/\r?\n\r?\n/)[3] + end + + def parse_responsexml(str) + str.split(/\r?\n\r?\n/)[6] + end +end + + +end; end + +end diff --git a/test/wsdl/simpletype/rpc/expectedClient.rb b/test/wsdl/simpletype/rpc/expectedClient.rb new file mode 100644 index 000000000..55eb58c3d --- /dev/null +++ b/test/wsdl/simpletype/rpc/expectedClient.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +require 'echo_versionDriver.rb' + +endpoint_url = ARGV.shift +obj = Echo_version_port_type.new(endpoint_url) + +# run ruby with -d to see SOAP wiredumps. +obj.wiredump_dev = STDERR if $DEBUG + +# SYNOPSIS +# echo_version(version) +# +# ARGS +# version Version - {urn:example.com:simpletype-rpc-type}version +# +# RETURNS +# version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct +# +version = nil +puts obj.echo_version(version) + +# SYNOPSIS +# echo_version_r(version_struct) +# +# ARGS +# version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct +# +# RETURNS +# version Version - {urn:example.com:simpletype-rpc-type}version +# +version_struct = nil +puts obj.echo_version_r(version_struct) + + diff --git a/test/wsdl/simpletype/rpc/expectedDriver.rb b/test/wsdl/simpletype/rpc/expectedDriver.rb new file mode 100644 index 000000000..81c72d1ac --- /dev/null +++ b/test/wsdl/simpletype/rpc/expectedDriver.rb @@ -0,0 +1,62 @@ +require 'echo_version.rb' + +require 'soap/rpc/driver' + +class Echo_version_port_type < ::SOAP::RPC::Driver + DefaultEndpointUrl = "http://localhost:10080" + MappingRegistry = ::SOAP::Mapping::Registry.new + + MappingRegistry.set( + Version_struct, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("urn:example.com:simpletype-rpc-type", "version_struct") } + ) + + Methods = [ + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version"), + "urn:example.com:simpletype-rpc", + "echo_version", + [ ["in", "version", ["::SOAP::SOAPString"]], + ["retval", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ], + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version_r"), + "urn:example.com:simpletype-rpc", + "echo_version_r", + [ ["in", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]], + ["retval", "version", ["::SOAP::SOAPString"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ] + ] + + def initialize(endpoint_url = nil) + endpoint_url ||= DefaultEndpointUrl + super(endpoint_url, nil) + self.mapping_registry = MappingRegistry + init_methods + end + +private + + def init_methods + Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + add_document_operation(*definitions) + else + add_rpc_operation(*definitions) + qname = definitions[0] + name = definitions[2] + if qname.name != name and qname.name.capitalize == name.capitalize + ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg| + __send__(name, *arg) + end + end + end + end + end +end + diff --git a/test/wsdl/simpletype/rpc/expectedEchoVersion.rb b/test/wsdl/simpletype/rpc/expectedEchoVersion.rb new file mode 100644 index 000000000..806ece162 --- /dev/null +++ b/test/wsdl/simpletype/rpc/expectedEchoVersion.rb @@ -0,0 +1,23 @@ +require 'xsd/qname' + +# {urn:example.com:simpletype-rpc-type}version_struct +class Version_struct + @@schema_type = "version_struct" + @@schema_ns = "urn:example.com:simpletype-rpc-type" + @@schema_element = [["version", ["SOAP::SOAPString", XSD::QName.new(nil, "version")]], ["msg", ["SOAP::SOAPString", XSD::QName.new(nil, "msg")]]] + + attr_accessor :version + attr_accessor :msg + + def initialize(version = nil, msg = nil) + @version = version + @msg = msg + end +end + +# {urn:example.com:simpletype-rpc-type}version +module Version + C_16 = "1.6" + C_18 = "1.8" + C_19 = "1.9" +end diff --git a/test/wsdl/simpletype/rpc/expectedServant.rb b/test/wsdl/simpletype/rpc/expectedServant.rb new file mode 100644 index 000000000..81cf50218 --- /dev/null +++ b/test/wsdl/simpletype/rpc/expectedServant.rb @@ -0,0 +1,32 @@ +require 'echo_version.rb' + +class Echo_version_port_type + # SYNOPSIS + # echo_version(version) + # + # ARGS + # version Version - {urn:example.com:simpletype-rpc-type}version + # + # RETURNS + # version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct + # + def echo_version(version) + p [version] + raise NotImplementedError.new + end + + # SYNOPSIS + # echo_version_r(version_struct) + # + # ARGS + # version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct + # + # RETURNS + # version Version - {urn:example.com:simpletype-rpc-type}version + # + def echo_version_r(version_struct) + p [version_struct] + raise NotImplementedError.new + end +end + diff --git a/test/wsdl/simpletype/rpc/expectedService.rb b/test/wsdl/simpletype/rpc/expectedService.rb new file mode 100644 index 000000000..be6f99656 --- /dev/null +++ b/test/wsdl/simpletype/rpc/expectedService.rb @@ -0,0 +1,60 @@ +#!/usr/bin/env ruby +require 'echo_versionServant.rb' + +require 'soap/rpc/standaloneServer' +require 'soap/mapping/registry' + +class Echo_version_port_type + MappingRegistry = ::SOAP::Mapping::Registry.new + + MappingRegistry.set( + Version_struct, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("urn:example.com:simpletype-rpc-type", "version_struct") } + ) + + Methods = [ + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version"), + "urn:example.com:simpletype-rpc", + "echo_version", + [ ["in", "version", ["::SOAP::SOAPString"]], + ["retval", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ], + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version_r"), + "urn:example.com:simpletype-rpc", + "echo_version_r", + [ ["in", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]], + ["retval", "version", ["::SOAP::SOAPString"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ] + ] +end + +class Echo_version_port_typeApp < ::SOAP::RPC::StandaloneServer + def initialize(*arg) + super(*arg) + servant = Echo_version_port_type.new + Echo_version_port_type::Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + @router.add_document_operation(servant, *definitions) + else + @router.add_rpc_operation(servant, *definitions) + end + end + self.mapping_registry = Echo_version_port_type::MappingRegistry + end +end + +if $0 == __FILE__ + # Change listen port. + server = Echo_version_port_typeApp.new('app', nil, '0.0.0.0', 10080) + trap(:INT) do + server.shutdown + end + server.start +end diff --git a/test/wsdl/simpletype/rpc/rpc.wsdl b/test/wsdl/simpletype/rpc/rpc.wsdl new file mode 100644 index 000000000..91f71a883 --- /dev/null +++ b/test/wsdl/simpletype/rpc/rpc.wsdl @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<definitions name="echo_version" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="urn:example.com:simpletype-rpc" + xmlns:txd="urn:example.com:simpletype-rpc-type" + targetNamespace="urn:example.com:simpletype-rpc" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + <types> + <xsd:schema targetNamespace="urn:example.com:simpletype-rpc-type"> + <xsd:complexType name="version_struct"> + <xsd:all> + <xsd:element name="version" type="txd:version" /> + <xsd:element name="msg" type="xsd:string" /> + </xsd:all> + </xsd:complexType> + + <xsd:simpleType name="version"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="1.6"/> + <xsd:enumeration value="1.8"/> + <xsd:enumeration value="1.9"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:schema> + </types> + + <message name="msg_version"> + <part name="version" type="txd:version"/> + </message> + + <message name="msg_version_struct"> + <part name="version_struct" type="txd:version_struct"/> + </message> + + <portType name="echo_version_port_type"> + <operation name="echo_version"> + <input message="tns:msg_version"/> + <output message="tns:msg_version_struct"/> + </operation> + + <operation name="echo_version_r"> + <input message="tns:msg_version_struct"/> + <output message="tns:msg_version"/> + </operation> + </portType> + + <binding name="echo_version_binding" type="tns:echo_version_port_type"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> + <operation name="echo_version"> + <soap:operation soapAction="urn:example.com:simpletype-rpc"/> + <input> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </input> + <output> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </output> + </operation> + + <operation name="echo_version_r"> + <soap:operation soapAction="urn:example.com:simpletype-rpc"/> + <input> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </input> + <output> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </output> + </operation> + </binding> + + <service name="echo_version_service"> + <port name="echo_version_port" binding="tns:echo_version_binding"> + <soap:address location="http://localhost:10080"/> + </port> + </service> +</definitions> diff --git a/test/wsdl/simpletype/rpc/test_rpc.rb b/test/wsdl/simpletype/rpc/test_rpc.rb new file mode 100644 index 000000000..1d6a3eb4b --- /dev/null +++ b/test/wsdl/simpletype/rpc/test_rpc.rb @@ -0,0 +1,50 @@ +require 'test/unit' +require 'wsdl/parser' +require 'wsdl/soap/wsdl2ruby' + + +module WSDL; module SimpleType + + +class TestRPC < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + def pathname(filename) + File.join(DIR, filename) + end + + def test_rpc + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("rpc.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['driver'] = nil + gen.opt['client_skelton'] = nil + gen.opt['servant_skelton'] = nil + gen.opt['standalone_server_stub'] = nil + gen.opt['force'] = true + gen.run + compare("expectedEchoVersion.rb", "echo_version.rb") + compare("expectedDriver.rb", "echo_versionDriver.rb") + compare("expectedService.rb", "echo_version_service.rb") + compare("expectedClient.rb", "echo_version_serviceClient.rb") + compare("expectedServant.rb", "echo_versionServant.rb") + + File.unlink(pathname("echo_version.rb")) + File.unlink(pathname("echo_versionDriver.rb")) + File.unlink(pathname("echo_version_service.rb")) + File.unlink(pathname("echo_version_serviceClient.rb")) + File.unlink(pathname("echo_versionServant.rb")) + end + + def compare(expected, actual) + assert_equal(loadfile(expected), loadfile(actual), actual) + end + + def loadfile(file) + File.open(pathname(file)) { |f| f.read } + end +end + + +end; end |