1use strict; 2use warnings; 3use Test::More tests => 13; 4use File::Spec; 5use File::Basename qw(dirname); 6use_ok qw(SOAP::WSDL); 7 8my $path = File::Spec->rel2abs(dirname( __FILE__ ) ); 9$path =~s{\\}{/}xmsg; # fix for windows 10my $soap = SOAP::WSDL->new(); 11$soap->wsdl("file://$path/WSDL_NOT_FOUND.wsdl"); 12 13eval { $soap->wsdlinit() }; 14like $@, qr{ does \s not \s exist }x, 'does not exist'; 15 16eval { $soap = SOAP::WSDL->new( 17 wsdl => "file://$path/WSDL_NOT_FOUND.wsdl"); 18}; 19like $@, qr{ does \s not \s exist }x, 'does not exist (constructor)'; 20 21$soap = SOAP::WSDL->new(); 22$soap->wsdl( "file://$path/WSDL_EMPTY_DEFINITIONS.wsdl"); 23eval { $soap->wsdlinit() }; 24like $@, qr{ unable \s to \s extract \s schema \s from \s WSDL }x, 'empty definition'; 25 26# Try out all call() variants 27eval { $soap->call('NewOperation', 'value'); }; 28like $@, qr{ unable \s to \s extract \s schema \s from \s WSDL }x, 'empty definition'; 29 30$soap = SOAP::WSDL->new(); 31$soap->wsdl( "file://$path/WSDL_NO_MESSAGE.wsdl"); 32eval { $soap->wsdlinit() }; 33# eval { $soap->call('NewOperation', 'value'); }; 34like $@, qr{ Message \s \{http://www.example.org/WSDL_1/\}NewOperationRequest \s not \s found }x, 'empty definition'; 35 36$soap = SOAP::WSDL->new(); 37$soap->wsdl( "file://$path/WSDL_1.wsdl"); 38$soap->wsdlinit(); 39$soap->no_dispatch(1); 40 41like $soap->call('NewOperation', NewOperation => { in => 'test' }), qr{ <in>test</in> }x; 42like $soap->call('NewOperation', { NewOperation => { in => 'test' } }), qr{ <in>test</in> }x; 43 44$soap->set_proxy('http://foo.de', timeout => 256); 45is $soap->get_client->get_transport()->timeout(), 256, 'timeout'; 46 47$soap = SOAP::WSDL->new( wsdl => "file://$path/WSDL_1.wsdl", 48 servicename => 'NewService', 49 portname => 'NewPort', 50 no_dispatch => 1, 51 keep_alive => 1, 52); 53$soap->proxy('http://example.org'); 54like $soap->call('NewOperation', NewOperation => { in => 'test' }), qr{ <in>test</in> }x; 55like $soap->call('NewOperation', { NewOperation => { in => 'test' } }), qr{ <in>test</in> }x; 56 57 58eval { 59 $soap = SOAP::WSDL->new( wsdl => "file://$path/WSDL_NO_BINDING.wsdl", 60 servicename => 'NewService', 61 portname => 'NewPort', 62 no_dispatch => 1, 63 ); 64}; 65like $@, qr{ no \s binding }x, 'No binding error'; 66 67eval { 68 $soap = SOAP::WSDL->new( wsdl => "file://$path/WSDL_NO_PORTTYPE.wsdl", 69 servicename => 'NewService', 70 portname => 'NewPort', 71 no_dispatch => 1, 72 ); 73}; 74like $@, qr{ cannot \s find \s portType }x, 'No porttype error'; 75