Provided by: libsoap-wsdl-perl_2.00.10-2_all bug

NAME

       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
       Moose

       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 => 'http://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

       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 'http://webservicex.net';    # might be better in the SOAP server interface
        _name 'GenerateBarCode';
        _elements
                BarCodeParam => 'MyTypes::BarCodeData',
                BarCodeText => 'string';

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

        <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;