Author image Edward Kawas
and 1 contributors

NAME

LS::Authority::WSDL::Simple - WSDL document describing a resource identified by an LSID.

SYNOPSIS

 # Generating WSDL

 use LS::Authority::WSDL::Constants;
 
 use LS::Authority::WSDL::Simple;

 $wsdl = LS::Authority::WSDL::Simple->new(
        authority => 'pdb.org',
        lsid => 'URN:LSID:pdb.org:pdb/cgi/explore.cgi:2ACE-6A6L0B72:',
        name => 'PDB',
 );

 # Add a HTTP Data port
 $port = LS::Authority::WSDL::Simple::DataPort->newData(
                        name=> 'HTTPData',
                        protocol=> $LS::Authority::WSDL::Constants::Protocols::HTTP, 
                        endpoint=> 'http://www.server-with-object.com/where/the/file/is/file.txt',
                );

 $wsdl->addPort (
        serviceName=> $wsdl->name(),
        port=> $port,
 );
 
 # Add a SOAP Metadata port
 $port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
                        name=> 'SOAPMetadata',
                        protocol=> $LS::Authority::WSDL::Constants::Protocols::SOAP, 
                        endpoint=> 'http://www.server-with-object.com/metaDataService/', 
                );
                
 $wsdl->addPort(
        serviceName=> 'metadataServiceName',
        port=> $port,
 );

 print $wsdl->xml();

or

 # Parsing WSDL

 use LS::Authority::WSDL::Simple;

 local $/ = undef;

 open FILE, 'wsdl.xml';
 $xml = <FILE>;
 close FILE;

 my $wsdl = LS::Authority::WSDL::Simple->from_xml($xml);

 print "getData locations\n";
 
 $locations = $wsdl->getDataLocations();

 if ($locations) {
 
        foreach $loc (@$locations) {
        
                print "\t", $loc->protocol(), ': ', $loc->url(), "\n";
        }
 }

 print "getMetadata locations\n";

 $locations = $wsdl->getMetadataLocations();

 if ($locations) {
 
        foreach $loc (@$locations) {
        
                print "\t", $loc->protocol(), ': ', $loc->url(), "\n";
        }
 }

DESCRIPTION

LS::Authority::WSDL::Simple provides a simple interface for creating WSDL documents when implementing the getAvailableOperations method in an LSID authority service, and for parsing the WSDL on the client side.

CONSTRUCTORS

The following methods are used to construct a new LS::Authority::WSDL::Simple object:

new ( [%options] )

This class method creates a new LS::Authority::WSDL::Simple object and returns it. Key/value pair arguments may be provided to initialize locator options. The options can also be set or modified later by method calls described below.

from_xml ( $xml )

This class method creates a new LS::Authority::WSDL::Simple object and returns it. The $xml paramater is a string containing a valid WSDL XML document. The newly created object is populated by parsing this XML document.

METHODS

name ( [$new_name] )

Sets and retrieves the descriptive name of the authority service that is creating the WSDL. This name is used to generate identifiers in the WSDL document, so it should be fairly short, and should not contain characters not allowed in XML identifiers, e.g. whitespace.

authority ( [$new_authority] )

Sets and retrieves the hostname of the authority service that is creating the WSDL. This name is used to generate the targetNamespace of the definitions, so it should be unique for each authority.

lsid ( [$new_lsid] )

Sets and retrieves the LSID of the resource which this WSDL document describes. This ID is used to generate the targetNamespace of the definitions, so it should be unique for each resource.

addPort ( %keys_and_values )

Adds a port to the WSDL document. The port is described by supplying the following key/value pairs:

serviceName - The name of the service, contained in this WSDL object, that will own the newly created port.

port - An object of type LS::Authority::WSDL::Port describing the characteristics of the port. Use the helper methods from the following classes to create the appropriate port:

LS::Authority::WSDL::Simple::DataPort or LS::Authority::WSDL::Simple::MetadataPort

Generally, the methods in the above two classes support the following parameters passed as an options hash:

    protocol - Specifies the transport protocol. This can be one of $LS::Authority::WSDL::Protocols::HTTP, $LS::Authority::WSDL::Protocols::FTP, or $LS::Authority::WSDL::Protocols::SOAP.

    method - Specifies the HTTP method to be used, e.g. 'GET' or 'POST'. This defaults to 'GET', and is ignored if the protocol is not $LS::Authority::WSDL::Protocols::HTTP.

    username - Specifies the username to be used for authentication.

    password - Specifies the password to be used for authentication.

    endpoint - Specifies the location of the port. For HTTP and FTP ports, this should be the hostname:portnumber. For SOAP ports, this should be the complete HTTP URL. Other SOAP transports are not supported.

    expires - Specifies whether or not an expires header message part will be added to output message bindings for SOAP ports. A true value causes the message part to appear in the bindings. This is ignored if the protocol is not $LS::Authority::WSDL::Protocols::SOAP.

Examples creating WSDL ports:

 # Add a HTTP Data port
 $port = LS::Authority::WSDL::Simple::DataPort->newData(
                        name=> 'HTTPData',
                        protocol=> $LS::Authority::WSDL::Protocols::HTTP, 
                        endpoint=> 'http://www.server-with-object.com/where/the/file/is/file.txt',
                );

 $wsdl->addPort (
        serviceName=> $wsdl->name(),
        port=> $port,
 );
 
 # Add a SOAP Metadata port
 $port = LS::Authority::WSDL::Simple::MetadataPort->newMetadata(
                        name=> 'SOAPMetadata',
                        protocol=> $LS::Authority::WSDL::Protocols::SOAP, 
                        endpoint=> 'http://www.server-with-object.com/metaDataService/', 
                );
                
 $wsdl->addPort(
        serviceName=> 'metadataServiceName',
        port=> $port,
 );
getMetadataLocations( %options )

Returns the locations at which the given method of the resource may be found. The return value is a reference to an array of objects of class LS::Authority::WSDL::Simple::Location, or undef if the method is not available. The location objects have three members, as shown in the example.

 $locations = $wsdl->getMetadataLocations();

 if ($locations) {
 
        foreach $loc (@$locations) {
        
                $protocol = $loc->protocol();  # a string, either $LS::Authority::WSDL::Constants::Protocols::HTTP, 
                                               # $LS::Authority::WSDL::Constants::Protocols::FTP, 
                                               # or $LS::Authority::WSDL::Constants::Protocols::SOAP
                                               
                $url = $loc->url(); # a string

                if ($protocol eq $LS::Authority::WSDL::Constants::Protocols::HTTP) {
                
                        $method = $loc->method(); # if protocol is HTTP, this is the HTTP method, eg 'GET'
                }
        }
 }
 
getDataLocations( %options )

Returns an arrayref of data locations for this service. See getMetadataLocations for more information.

xml ( )

Returns the WSDL document as an XML string.

COPYRIGHT

Copyright (c) 2002,2003 IBM Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at http://www.opensource.org/licenses/cpl.php

NAME

LS::Authority::WSDL::Simple::Location - Object describing a WSDL port's location

SYNOPSIS

 use LS::Authority::WSDL::Constants;
 use LS::Authority::WSDL::Simple;
 
 # Creata a new data location
 my $loc = LS::Authority::WSDL::Simple::Location->new(
                protocol=> $LS::Authority::WSDL::Constants::Protocols::HTTP,
                url=> 'http://www.someplace.com/data.txt',
                binding=> 'LSIDDataServiceHTTPBinding',
                method=> $LS::Authority::WSDL::Constants::Protocols::HTTP_GET,
                name=> 'portName',
                parentName=> 'Name of Parent Service',
        );
 

DESCRIPTION

METHODS

protocol( [$protocol] )
        Returns the protocol that is used to access this location. If 
        a protocol is passed as a parameter, the protocol for this location
        will be set to the value of the parameter.
        
url( [$url] )
        Returns the URL endpoint of this location. If a URL is passed as a
        parametere, the URL for this location will be set to the value of 
        the parameter.
method( [$method] )
        In the case of HTTP locations, returns the method used: GET or POST.
        If a method is passed as a parameter, the method for this location
        will be set to the value of the parameter.
name( [$name] )
        Returns the name of this location. If a name is passed as a parameter,
        the name of this location will be set to the value of the parameter.
        
serviceName( [$serviceName] )
        Returns the name of the parent service for this location. If a service
        name is specified as a parameter, then the parent service name of this
        location will be set to the value of the parameter.

COPYRIGHT

Copyright (c) 2002,2003 IBM Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at http://www.opensource.org/licenses/cpl.php