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


WSDL-Generator documentation Contained in the WSDL-Generator distribution.

Index


Code Index:

NAME

Top

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

SYNOPSIS

Top

  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;

CONSTRUCTOR

Top

new($param)

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

METHODS

Top

add_request($method)

Adds a method with its request for binding

add_reponse($method)

Adds a method with its response for binding

generate($param)

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

get_message()

Returns WSDL message object

get_porttype()

Returns WSDL porttype object

get_binding()

Returns WSDL binding object

SEE ALSO

Top

  WSDL::Generator

AUTHOR

Top

"Pierre Denis" <pdenis@fotango.com>

COPYRIGHT

Top


WSDL-Generator documentation Contained in the WSDL-Generator distribution.
package WSDL::Generator::Binding;

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

our $VERSION = '0.01';

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

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

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

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',
		                                        } )};
		push @binding, @{$self->get_wsdl_element( { wsdl_type        => 'BINDING_OPERATION',
		                                            method          => $method,
		                                            definition_name => $self->{service_name},
		                                        } )};
	}
	$self->{message}  = bless \@message => ref($self);
	$self->{binding}  = $self->get_wsdl_element( { wsdl_type         => 'BINDING',
						                           binding_operation => \@binding,
													%$self,
			                                        } );
	$self->{porttype} = $self->get_wsdl_element( { wsdl_type          => 'PORTTYPE',
						                           porttype_operation => \@porttype,
													%$self,
			                                        } );
	return $self;
}


sub get_message : method {
	my $self = shift;
	exists $self->{message} or $self->generate;
	return $self->{message};
}


sub get_porttype : method {
	my $self = shift;
	exists $self->{porttype} or $self->generate;
	return $self->{porttype};
}


sub get_binding : method {
	my $self = shift;
	exists $self->{binding} or $self->generate;
	return $self->{binding};
}

1;