NAME

XML::Compile::SOAP::Tester - test SOAP without daemon

INHERITANCE

SYNOPSIS

# Do this BEFORE the client SOAP handlers are compiled!
use XML::Compile::SOAP::Tester ();
my $tester = XML::Compile::SOAP::Tester->new(@options);

my $action = pack_type $my_ns, 'GetStockPrice';
sub get_stock_price(@) {...}

#
# with WSDL
#

use XML::Compile::WSDL11 ();
my $wsdl    = XML::Compile::WSDL11->new('my_wsdl.xml');
my $call    = $wsdl->prepareClient($action);
$tester->fromWSDL($wsdl);
$tester->addCallback($action, \&get_stock_price);

my $answer  = $call->($query);

#
# without WSDL
#

use XML::Compile::Util   'pack_type';
use XML::Compile::SOAP11::Client ();
use XML::Compile::SOAP11::Server ();

my $client = XML::Compile::SOAP11::Client->new;
my $call   = $client->compileRequest(...);

my $server = XML::Compile::SOAP11::Server->new;
my $answer = $server->compileAnswer(  ... \&get_stock_price);
$tester->actionCallback($my_action, $answer, $server);

my $answer = $call->($query);

DESCRIPTION

Once you have instantiated this object, all compiled client calls will get re-routed to methods within the object. This is useful for debugging and regression tests.

If you install the XML-Compile-SOAP-Server distribution, you will have an XML::Compile::SOAP::HTTPTester implementation, which simulates a remote server in a much more realistic way.

METHODS

XML::Compile::SOAP::Tester->new(OPTIONS)

    Option   --Default
    callbacks  {}

    . callbacks => HASH | ARRAY

      The HASH contains pairs of action-uri to code reference. Each pair is used to call actionCallback(). The ARRAY contains two elements: a string SOAP11, SOAP12, or XML::Compile::SOAP object as first, and the HASH as second. To be precise: when only a HASH is passed, it is the same as an ARRAY with ANY and that HASH.

Attributes

$obj->actionCallback(ACTION, CODE, ['SOAP11'|'SOAP12'|SOAP|'ANY'])

    Change the callback of an ACTION to the CODE reference. By default, all known (ANY) soap versions will be affected. Callback changes to undefined actions are ignored.

Run the server

$obj->request(OPTIONS)

    Fake a request to a remote server. Which information is passed as the OPTIONS depends partially on the protocol.

SEE ALSO

This module is part of XML-Compile-SOAP distribution version 0.59, built on November 05, 2007. Website: http://perl.overmeer.net/xml-compile/

LICENSE

Copyrights 2007 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html