ePages 6.11.0 - DE_EPAGES/WebService/API/Object/WebServiceSession.pm

Package DE_EPAGES::WebService::API::Object::WebServiceSession

object interface for WS Session.

Base
DE_EPAGES::Object::API::Object::Object

Functions

doSub
end
error
insert
setSub
status

doSub

start the stored method with the parameters (see setSub) service: may based on WebService::API::WebService::BaseAsyncService aParams: all necessary parameters of the method $WSession object passed to have easy acces to the session status etc.

Syntax
my $ret = $WSession->doSub();
Return
$ret (scalar or array)
result of the function execution

end

set status code=0 and passed status mesage

Syntax
$WSession->end;
$WSession->end( $StatusMessage );
Example
$WSession->end( 'method finished' );
Input
$StatusMessage (string)
status message (optional)

error

set status code=-1 and passed error mesage

Syntax
$WSession->error;
$WSession->error( $ErrorMessage );
Example
$WSession->error( 'error occured' );
Input
$ErrorMessage (string)
error message (optional)

insert

Insert this info as web service session object

Syntax
$WSession = DE_EPAGES::WebService::API::Object::WebServiceSession->insert($hInfo);
Example
my $WSessionFolder = LoadRootObject()->folder('WebServiceSessions');
my $WSession = $WSessionFolder->insertChild('WebServiceSession');
Input
$hInfo (ref.hash)
attributes of new web service session object
Return
$WSession (object)
new web service session object

setSub

remember references to service: may based on WebService::API::WebService::BaseAsyncService code: reference to a Webservice method with expected long running time aParams: all necesary parameters of thje method this configuration will later use to start and run the method after sending the response back to the client the method should chnage the status ti signal the progressing and the end

Syntax
$WSession->setSub( $service, $code, $aParams );
Example
$WSession->setSub( $ExampleWebService, \&doLongTimeFunc, [$CountParam] );
$WSession->setSub( $ExampleWebService, sub {...}, \@Input );
Input
$service (object)
web service object
$code (ref.code)
web service method reference
$aParams (ref.array)
parameter array reference

status

set status code and status method of Webservice Session returns current status code and method if no code passed status code <0 should be used for errors status code 0 is used if method finished (see method $self->end) status code 1 is used if session started (see method insert) status codes >1 should be used for method progress and should be increased

Syntax
$WSession->status( $StatusCode, $StatusMessage );
( $StatusCode, $StatusMessage ) = $WSession->status;
Example
$WSession->status( -1, 'wrong parameter' )
$WSession->status( 0, 'method finished' )
$WSession->status( 1, 'method started' )
my ( $code, $msg ) = $WSession->status()
Input
$StatusCode (int)
status code (optional)
$StatusMessage (string)
status message (optional)
Return
$StatusCode (int)
status code
$StatusMessage (string)
status message