Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
SOAP::WSDL::Manual::CoUserrContributed Perl DoSOAP::WSDL::Manual::CodeFirst(3)

       CodeFirst - Writing Code-First Web Services with	SOAP::WSDL

       Note: This document is just a collection	of thought. There's no
       implementation yet.

   How Data Class definitions could look like

       Of course SOAP::WSDL could (and probably	should)	just use Moose - it
       provides	the full Metaclass Framework needed for	generating Schemas
       from class definitions.

       However,	Moose is way too powerful for building (just) simple Data
       Transfer	Objects	which can be expressed in XML.

       With Moose, a class could look like this:

	package	MyElements::GenerateBarCode;
	use Moose;

	has 'xmlns' =>
	    is => 'ro',
	    default => '';

	has 'xmlname' =>
	    is => 'ro',
	    default => 'GenerateBarCode';

	has 'BarCodeParam' =>
	     is	=> 'rw',
	     type => 'MyTypes::BarCodeData';

	has 'BarCodeText' =>
	     is	=> 'rw',
	     type => 'String';

       This is - despite the condensed syntax -	a lot of line noise.

       Native SOAP::WSDL

       SOAP::WSDL::XSD::Typelib::ComplexType (should) provide a	simple setup
       method allowing a even shorter description (and offering	the additional
       performance boost SOAP::WSDL has	over Moose):

	package	MyElements::GenerateBarCode;
	use strice; use	warnings;
	use SOAP::WSDL::XSD::Typelib::Element;
	use SOAP::WSDL::XSD::Typelib::ComplexType;

	_namespace '';	# might	be better in the SOAP server interface
	_name 'GenerateBarCode';
		BarCodeParam =>	'MyTypes::BarCodeData',
		BarCodeText => 'string';

       This would result in the	following XML Schema (inside a schema with the
       namespace "" - the	namespaces could even be
       declared	outside	the DTO	classes.

	<complexType name="GenerateBarCode">
		  <element name="BarCodeParam" type="tns:BarCodeData"/>
		  <element name="BarCodeText" type="xsd:string"/>

   Interface definitions
       Perl does not have the concept of interfaces. However, Moose provides
       Roles, which can	be used	for defining interfaces.

       However,	it's not really	necessary to define a interface	Interface (in
       the sense of a Java interface) -	a interface class is sufficient.

       Subroutine attributes could be used for providing additional
       information - attributes	in perl	are much like annotations in Java

       A interface could look like this:

	package	MyServer::BarCode;
	use strict; use	warnings;
	use SOAP::WSDL::Server::CodeFirst;

	sub generateBarCode :WebMethod(name=<GenerateBarCode>
	    body=<MyElements::GenerateBarcode>)	{
	    my ($self, $body, $header) = @_;
	    my $result = MyElements::GenerateBarcodeResponse->new();
	    return $result;

perl v5.32.1			  2020-01-20  SOAP::WSDL::Manual::CodeFirst(3)


Want to link to this manual page? Use this URL:

home | help