import SOAP-WSDL 2.00_11 from CPAN
git-cpan-module: SOAP-WSDL git-cpan-version: 2.00_11 git-cpan-authorid: MKUTTER git-cpan-file: authors/id/M/MK/MKUTTER/SOAP-WSDL-2.00_11.tar.gz
This commit is contained in:
committed by
Michael G. Schwern
parent
7ba1959888
commit
c2da74b5ae
@@ -3,6 +3,7 @@ use strict;
|
||||
use Class::Std::Storable;
|
||||
use SOAP::WSDL::XSD::Typelib::Element;
|
||||
|
||||
|
||||
# atomic complexType
|
||||
# <element name="GetCitiesByCountry"><complexType> definition
|
||||
use SOAP::WSDL::XSD::Typelib::ComplexType;
|
||||
@@ -16,7 +17,7 @@ my %CountryName_of :ATTR(:get<CountryName>);
|
||||
|
||||
|
||||
__PACKAGE__->_factory(
|
||||
[ qw(
|
||||
[ qw(
|
||||
CountryName
|
||||
) ],
|
||||
{
|
||||
@@ -25,8 +26,8 @@ __PACKAGE__->_factory(
|
||||
},
|
||||
{
|
||||
|
||||
CountryName => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
CountryName => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
@@ -46,9 +47,16 @@ __PACKAGE__->__set_ref('');
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME MyElements::GetCitiesByCountry
|
||||
=head1 NAME
|
||||
|
||||
MyElements::GetCitiesByCountry
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use strict;
|
||||
use Class::Std::Storable;
|
||||
use SOAP::WSDL::XSD::Typelib::Element;
|
||||
|
||||
|
||||
# atomic complexType
|
||||
# <element name="GetCitiesByCountryResponse"><complexType> definition
|
||||
use SOAP::WSDL::XSD::Typelib::ComplexType;
|
||||
@@ -16,7 +17,7 @@ my %GetCitiesByCountryResult_of :ATTR(:get<GetCitiesByCountryResult>);
|
||||
|
||||
|
||||
__PACKAGE__->_factory(
|
||||
[ qw(
|
||||
[ qw(
|
||||
GetCitiesByCountryResult
|
||||
) ],
|
||||
{
|
||||
@@ -25,8 +26,8 @@ __PACKAGE__->_factory(
|
||||
},
|
||||
{
|
||||
|
||||
GetCitiesByCountryResult => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
GetCitiesByCountryResult => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
@@ -46,9 +47,16 @@ __PACKAGE__->__set_ref('');
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME MyElements::GetCitiesByCountryResponse
|
||||
=head1 NAME
|
||||
|
||||
MyElements::GetCitiesByCountryResponse
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use strict;
|
||||
use Class::Std::Storable;
|
||||
use SOAP::WSDL::XSD::Typelib::Element;
|
||||
|
||||
|
||||
# atomic complexType
|
||||
# <element name="GetWeather"><complexType> definition
|
||||
use SOAP::WSDL::XSD::Typelib::ComplexType;
|
||||
@@ -18,9 +19,9 @@ my %CountryName_of :ATTR(:get<CountryName>);
|
||||
|
||||
|
||||
__PACKAGE__->_factory(
|
||||
[ qw(
|
||||
[ qw(
|
||||
CityName
|
||||
|
||||
|
||||
CountryName
|
||||
) ],
|
||||
{
|
||||
@@ -30,11 +31,11 @@ __PACKAGE__->_factory(
|
||||
},
|
||||
{
|
||||
|
||||
CityName => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
CityName => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
|
||||
CountryName => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
CountryName => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
@@ -54,9 +55,16 @@ __PACKAGE__->__set_ref('');
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME MyElements::GetWeather
|
||||
=head1 NAME
|
||||
|
||||
MyElements::GetWeather
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use strict;
|
||||
use Class::Std::Storable;
|
||||
use SOAP::WSDL::XSD::Typelib::Element;
|
||||
|
||||
|
||||
# atomic complexType
|
||||
# <element name="GetWeatherResponse"><complexType> definition
|
||||
use SOAP::WSDL::XSD::Typelib::ComplexType;
|
||||
@@ -16,7 +17,7 @@ my %GetWeatherResult_of :ATTR(:get<GetWeatherResult>);
|
||||
|
||||
|
||||
__PACKAGE__->_factory(
|
||||
[ qw(
|
||||
[ qw(
|
||||
GetWeatherResult
|
||||
) ],
|
||||
{
|
||||
@@ -25,7 +26,8 @@ __PACKAGE__->_factory(
|
||||
},
|
||||
{
|
||||
|
||||
GetWeatherResult => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
GetWeatherResult => 'SOAP::WSDL::XSD::Typelib::Builtin::string',
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
@@ -45,9 +47,16 @@ __PACKAGE__->__set_ref('');
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME MyElements::GetWeatherResponse
|
||||
=head1 NAME
|
||||
|
||||
MyElements::GetWeatherResponse
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use strict;
|
||||
use Class::Std::Storable;
|
||||
use SOAP::WSDL::XSD::Typelib::Element;
|
||||
|
||||
|
||||
#
|
||||
# <element name="string" type="s:string"/> definition
|
||||
#
|
||||
@@ -26,9 +27,16 @@ __PACKAGE__->__set_ref('');
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME MyElements::string
|
||||
=head1 NAME
|
||||
|
||||
MyElements::string
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package MyInterfaces::GlobalWeather;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use MyTypemaps::GlobalWeather;
|
||||
@@ -16,15 +17,29 @@ sub new {
|
||||
}
|
||||
|
||||
__PACKAGE__->__create_methods(
|
||||
GetWeather => [ 'MyElements::GetWeather', ],
|
||||
GetCitiesByCountry => [ 'MyElements::GetCitiesByCountry', ],
|
||||
|
||||
GetWeather => {
|
||||
parts => [ 'MyElements::GetWeather', ],
|
||||
soap_action => 'http://www.webserviceX.NET/GetWeather',
|
||||
style => 'document',
|
||||
# use => '', # use not implemented yet
|
||||
},
|
||||
GetCitiesByCountry => {
|
||||
parts => [ 'MyElements::GetCitiesByCountry', ],
|
||||
soap_action => 'http://www.webserviceX.NET/GetCitiesByCountry',
|
||||
style => 'document',
|
||||
# use => '', # use not implemented yet
|
||||
},
|
||||
|
||||
);
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
@@ -64,5 +79,5 @@ SYNOPSIS:
|
||||
|
||||
|
||||
|
||||
=cut
|
||||
=pod
|
||||
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ use MyInterfaces::GlobalWeather;
|
||||
my $weather = MyInterfaces::GlobalWeather->new();
|
||||
my $result = $weather->GetWeather({ CountryName => 'Germany', CityName => 'Munich' });
|
||||
|
||||
die $result->get_faultstring()->get_value() if not ($result); # boolean comparison overloaded
|
||||
# boolean comparison overloaded
|
||||
die $result->get_faultstring()->get_value() if not ($result);
|
||||
|
||||
print $result->get_GetWeatherResult()->get_value() , "\n";
|
||||
|
||||
+15
-1
@@ -22,4 +22,18 @@ my $som = $soap->wsdl("file:///$path/wsdl/globalweather.xml")
|
||||
|
||||
die $som->message() if $som->fault();
|
||||
|
||||
print $som->result();
|
||||
print $som->result();
|
||||
|
||||
|
||||
# SOAP::Lite variant:
|
||||
|
||||
use SOAP::Lite;
|
||||
my $soap = SOAP::Lite->new()->on_action( sub { join'/', @_ } )
|
||||
->proxy("http://www.webservicex.net/globalweather.asmx");
|
||||
my $som = $soap->call(
|
||||
SOAP::Data->name('GetWeather')->attr({ xmlns => 'http://www.webserviceX.NET' }),
|
||||
SOAP::Data->name('CountryName')->value('Germany'),
|
||||
SOAP::Data->name('CityName')->value('Munich')
|
||||
);
|
||||
|
||||
print $som->result();
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Accessing the globalweather service at
|
||||
# www.webservicex.net/GlobalWeather/GlobalWeather.asmx
|
||||
#
|
||||
# Note that the GlobalWeather web service returns a (quoted) XML structure -
|
||||
# don't be surprised by the response's format.
|
||||
#
|
||||
# I have no connection to www.webservicex.net
|
||||
# Use this script at your own risk.
|
||||
#
|
||||
# This script demonstrates the use of SOAP::WSDL in SOAP::Lite style.
|
||||
=for later
|
||||
use lib 'lib/';
|
||||
use lib '../lib';
|
||||
use SOAP::WSDL;
|
||||
use File::Basename qw(dirname);
|
||||
use File::Spec;
|
||||
my $path = File::Spec->rel2abs( dirname __FILE__);
|
||||
|
||||
my $soap = SOAP::WSDL->new();
|
||||
my $som = $soap->wsdl("file:///$path/wsdl/globalweather.xml")->no_dispatch(1)
|
||||
->call('GetWeather', GetWeather => { CountryName => 'Germany', CityName => 'Munich' });
|
||||
|
||||
print $som;
|
||||
|
||||
=for later use
|
||||
|
||||
die $som->message() if $som->fault();
|
||||
|
||||
print $som->result();
|
||||
|
||||
=cut
|
||||
|
||||
use Carp;
|
||||
use diagnostics;
|
||||
|
||||
use XML::Compile::WSDL;
|
||||
my $schema = XML::Compile::WSDL->new('wsdl/globalweather.xml',
|
||||
schema_dirs => 'D:/Test/XMLC/'
|
||||
);
|
||||
|
||||
my $operation = $schema->prepare('GetWeather', role => 'CLIENT', port => 'GlobalWeatherSoap');
|
||||
use Data::Dumper;
|
||||
print Dumper $operation;
|
||||
Reference in New Issue
Block a user