SOAP::WSDL::Manual::CodeFirst (3)
Leading comments
Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) Standard preamble: ========================================================================
NAME
CodeFirst - Writing Code-First Web Services with SOAP::WSDLNote: This document is just a collection of thought. There's no implementation yet.
How Data Class definitions could look like
MooseOf course
However, Moose is way too powerful for building (just) simple Data Transfer Objects which can be expressed in
With Moose, a class could look like this:
package MyElements::GenerateBarCode; use Moose; has 'xmlns' => is => 'ro', default => 'webservicex.net'; has 'xmlname' => is => 'ro', default => 'GenerateBarCode'; has 'BarCodeParam' => is => 'rw', type => 'MyTypes::BarCodeData'; has 'BarCodeText' => is => 'rw', type => 'String'; 1;
This is - despite the condensed syntax - a lot of line noise.
Native
SOAP::WSDL::XSD::Typelib::ComplexType (should) provide a simple setup method allowing a even shorter description (and offering the additional performance boost
package MyElements::GenerateBarCode; use strice; use warnings; use SOAP::WSDL::XSD::Typelib::Element; use SOAP::WSDL::XSD::Typelib::ComplexType; _namespace 'webservicex.net'; # might be better in the SOAP server interface _name 'GenerateBarCode'; _elements BarCodeParam => 'MyTypes::BarCodeData', BarCodeText => 'string';
This would result in the following
<complexType name="GenerateBarCode"> <sequence> <element name="BarCodeParam" type="tns:BarCodeData"/> <element name="BarCodeText" type="xsd:string"/> </sequence> </complexType>
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> return=<MyElements::GenerateBarcodeResponse> body=<MyElements::GenerateBarcode>) { my ($self, $body, $header) = @_; my $result = MyElements::GenerateBarcodeResponse->new(); return $result; }; 1;