.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SOAP::WSDL::Manual::CodeFirst 3pm" .TH SOAP::WSDL::Manual::CodeFirst 3pm "2020-01-20" "perl v5.30.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CodeFirst \- Writing Code\-First Web Services with SOAP::WSDL .PP Note: This document is just a collection of thought. There's no implementation yet. .SS "How Data Class definitions could look like" .IX Subsection "How Data Class definitions could look like" \fIMoose\fR .IX Subsection "Moose" .PP Of course \s-1SOAP::WSDL\s0 could (and probably should) just use Moose \- it provides the full Metaclass Framework needed for generating Schemas from class definitions. .PP However, Moose is way too powerful for building (just) simple Data Transfer Objects which can be expressed in \s-1XML.\s0 .PP With Moose, a class could look like this: .PP .Vb 2 \& package MyElements::GenerateBarCode; \& use Moose; \& \& has \*(Aqxmlns\*(Aq => \& is => \*(Aqro\*(Aq, \& default => \*(Aqhttp://webservicex.net\*(Aq; \& \& has \*(Aqxmlname\*(Aq => \& is => \*(Aqro\*(Aq, \& default => \*(AqGenerateBarCode\*(Aq; \& \& has \*(AqBarCodeParam\*(Aq => \& is => \*(Aqrw\*(Aq, \& type => \*(AqMyTypes::BarCodeData\*(Aq; \& \& has \*(AqBarCodeText\*(Aq => \& is => \*(Aqrw\*(Aq, \& type => \*(AqString\*(Aq; \& 1; .Ve .PP This is \- despite the condensed syntax \- a lot of line noise. .PP \fINative \s-1SOAP::WSDL\s0\fR .IX Subsection "Native SOAP::WSDL" .PP SOAP::WSDL::XSD::Typelib::ComplexType (should) provide a simple setup method allowing a even shorter description (and offering the additional performance boost \s-1SOAP::WSDL\s0 has over Moose): .PP .Vb 4 \& package MyElements::GenerateBarCode; \& use strice; use warnings; \& use SOAP::WSDL::XSD::Typelib::Element; \& use SOAP::WSDL::XSD::Typelib::ComplexType; \& \& _namespace \*(Aqhttp://webservicex.net\*(Aq; # might be better in the SOAP server interface \& _name \*(AqGenerateBarCode\*(Aq; \& _elements \& BarCodeParam => \*(AqMyTypes::BarCodeData\*(Aq, \& BarCodeText => \*(Aqstring\*(Aq; .Ve .PP This would result in the following \s-1XML\s0 Schema (inside a schema with the namespace \&\*(L"http://webservicex.net\*(R" \- the namespaces could even be declared outside the \s-1DTO\s0 classes. .PP .Vb 6 \& \& \& \& \& \& .Ve .SS "Interface definitions" .IX Subsection "Interface definitions" Perl does not have the concept of interfaces. However, Moose provides Roles, which can be used for defining interfaces. .PP However, it's not really necessary to define a interface Interface (in the sense of a Java interface) \- a interface class is sufficient. .PP Subroutine attributes could be used for providing additional information \- attributes in perl are much like annotations in Java .PP A interface could look like this: .PP .Vb 3 \& package MyServer::BarCode; \& use strict; use warnings; \& use SOAP::WSDL::Server::CodeFirst; \& \& sub generateBarCode :WebMethod(name= \& return= \& body=) { \& my ($self, $body, $header) = @_; \& my $result = MyElements::GenerateBarcodeResponse\->new(); \& return $result; \& }; \& 1; .Ve