summaryrefslogtreecommitdiff
path: root/test/soap
diff options
context:
space:
mode:
Diffstat (limited to 'test/soap')
-rw-r--r--test/soap/asp.net/hello.wsdl96
-rw-r--r--test/soap/asp.net/test_aspdotnet.rb111
-rw-r--r--test/soap/header/test_simplehandler.rb116
-rw-r--r--test/soap/test_envelopenamespace.rb92
-rw-r--r--test/soap/test_httpconfigloader.rb39
-rw-r--r--test/soap/test_no_indent.rb86
6 files changed, 540 insertions, 0 deletions
diff --git a/test/soap/asp.net/hello.wsdl b/test/soap/asp.net/hello.wsdl
new file mode 100644
index 0000000000..b94129c152
--- /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 0000000000..7d5f3fd288
--- /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 0000000000..75dbd4a550
--- /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/test_envelopenamespace.rb b/test/soap/test_envelopenamespace.rb
new file mode 100644
index 0000000000..5b7d281341
--- /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 0000000000..b06243f661
--- /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 0000000000..f49fb7389f
--- /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