WSDL-Generator

 view release on metacpan or  search on metacpan

lib/WSDL/Generator/Binding.pm  view on Meta::CPAN

=pod

=head1 NAME

WSDL::Generator::Binding - Generate wsdl messages and portType for WSDL::Generator

=head1 SYNOPSIS

  use WSDL::Generator::Binding;
  my $param = {	'services'     => 'AcmeTravelCompany',
				'service_name' => 'Book_a_Flight' };
  my $bind = WSDL::Generator::Binding->new($param);
  $bind->add_request('GetPrice');
  $bind->add_response('GetPrice');
  print $bind->get_message->to_string;
  print $bind->get_porttype->to_string;
  print $bind->get_binding->to_string;

=cut
package WSDL::Generator::Binding;

use strict;
use warnings::register;
use Carp;
use base	qw(WSDL::Generator::Base);

our $VERSION = '0.01';

=pod

=head1 CONSTRUCTOR

=head2 new($param)

  $param = {	'services'     => 'AcmeTravelCompany',
				'service_name' => 'Book_a_Flight' };
$param is optional.
Returns WSDL::Generator::Binding object

=cut
sub new {
	my ($class, $param) = @_;
	my $self = { 'services'     => $param->{services},
				 'service_name' => $param->{service_name},
	             'methods'      => {} };
	return bless $self => $class;
}

=pod

=head1 METHODS

=head2 add_request($method)

Adds a method with its request for binding

=cut
sub add_request : method {
	my ($self, $method) = @_;
	$self->{methods}->{$method}->{request} = $method.'Request';
}

=pod

=head2 add_reponse($method)

Adds a method with its response for binding

=cut
sub add_response : method {
	my ($self, $method) = @_;
	$self->{methods}->{$method}->{response} = $method.'Response';
}

=pod

=head2 generate($param)

  $param = {	'services'     => 'AcmeTravelCompany',
				'service_name' => 'Book_a_Flight' };
$param is optional.
Prepare a wsdl structure ready to be fetched

=cut
sub generate : method {
	my ($self, $param) = @_;
	my @message  = ();
	my @porttype = ();
	my @binding  = ();
	$self->{service_name}  = $param->{service_name}  if (exists $param->{service_name});
	$self->{services} = $param->{services} if (exists $param->{services});
	$self->{service_name}  or return carp 'No service defined';
	$self->{services} or return carp 'No services name defined';
	foreach my $method (sort keys %{$self->{methods}} ) {
		push @message, @{$self->get_wsdl_element( { wsdl_type => 'MESSAGE',
		                                            methodRe  => $method.'Request',
			                                        type      => $self->{methods}->{$method}->{request},
		                                        } ) if ($self->{methods}->{$method}->{request})};
		push @message, @{$self->get_wsdl_element( { wsdl_type => 'MESSAGE',
		                                            methodRe  => $method.'Response',
		                                            type      => $self->{methods}->{$method}->{response},
		                                        } ) if ($self->{methods}->{$method}->{response})};
		push @porttype, @{$self->get_wsdl_element( { wsdl_type => 'PORTTYPE_OPERATION',
		                                             method    => $method,
		                                             request   => $method.'Request',
		                                             response  => $method.'Response',

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.763 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )