GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SOAP::WSDL::Manual::CodeFirst(3) User Contributed Perl Documentation SOAP::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.

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>

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;
2020-01-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.