1SOAP::WSDL::Manual::CodUesFeirrsCto(n3t)ributed Perl DocSuOmAePn:t:aWtSiDoLn::Manual::CodeFirst(3)
2
3
4

NAME

6       CodeFirst - Writing Code-First Web Services with SOAP::WSDL
7
8       Note: This document is just a collection of thought. There's no
9       implementation yet.
10
11   How Data Class definitions could look like
12       Moose
13
14       Of course SOAP::WSDL could (and probably should) just use Moose - it
15       provides the full Metaclass Framework needed for generating Schemas
16       from class definitions.
17
18       However, Moose is way too powerful for building (just) simple Data
19       Transfer Objects which can be expressed in XML.
20
21       With Moose, a class could look like this:
22
23        package MyElements::GenerateBarCode;
24        use Moose;
25
26        has 'xmlns' =>
27            is => 'ro',
28            default => 'http://webservicex.net';
29
30        has 'xmlname' =>
31            is => 'ro',
32            default => 'GenerateBarCode';
33
34        has 'BarCodeParam' =>
35             is => 'rw',
36             type => 'MyTypes::BarCodeData';
37
38        has 'BarCodeText' =>
39             is => 'rw',
40             type => 'String';
41        1;
42
43       This is - despite the condensed syntax - a lot of line noise.
44
45       Native SOAP::WSDL
46
47       SOAP::WSDL::XSD::Typelib::ComplexType (should) provide a simple setup
48       method allowing a even shorter description (and offering the additional
49       performance boost SOAP::WSDL has over Moose):
50
51        package MyElements::GenerateBarCode;
52        use strice; use warnings;
53        use SOAP::WSDL::XSD::Typelib::Element;
54        use SOAP::WSDL::XSD::Typelib::ComplexType;
55
56        _namespace 'http://webservicex.net';    # might be better in the SOAP server interface
57        _name 'GenerateBarCode';
58        _elements
59                BarCodeParam => 'MyTypes::BarCodeData',
60                BarCodeText => 'string';
61
62       This would result in the following XML Schema (inside a schema with the
63       namespace "http://webservicex.net" - the namespaces could even be
64       declared outside the DTO classes.
65
66        <complexType name="GenerateBarCode">
67             <sequence>
68                  <element name="BarCodeParam" type="tns:BarCodeData"/>
69                  <element name="BarCodeText" type="xsd:string"/>
70             </sequence>
71        </complexType>
72
73   Interface definitions
74       Perl does not have the concept of interfaces. However, Moose provides
75       Roles, which can be used for defining interfaces.
76
77       However, it's not really necessary to define a interface Interface (in
78       the sense of a Java interface) - a interface class is sufficient.
79
80       Subroutine attributes could be used for providing additional
81       information - attributes in perl are much like annotations in Java
82
83       A interface could look like this:
84
85        package MyServer::BarCode;
86        use strict; use warnings;
87        use SOAP::WSDL::Server::CodeFirst;
88
89        sub generateBarCode :WebMethod(name=<GenerateBarCode>
90            return=<MyElements::GenerateBarcodeResponse>
91            body=<MyElements::GenerateBarcode>) {
92            my ($self, $body, $header) = @_;
93            my $result = MyElements::GenerateBarcodeResponse->new();
94            return $result;
95        };
96        1;
97
98
99
100perl v5.32.0                      2020-07-28  SOAP::WSDL::Manual::CodeFirst(3)
Impressum