package TwoAsyncService;
use strict;
use SOAP::Lite;
use MOBY::CommonSubs qw(:all); 
use MOBY::Async::SimpleServer;
use vars qw(@ISA);
use base qw(MOBY::Async::SimpleServer);

# This variable is a subroutine which carry out the core of the service
my $serviceOne = sub {
   my ( $caller, $MOBY_message ) = @_;


     # ...
     # The code of your service
     # ...
   sleep(5);
   my $serviceRequest = <<END;
	<moby:mobyData queryID="1">
        	<moby:Simple moby:articleName="serviceOne">
			<moby:Object id="" namespace="" articleName="" /> 
		</moby:Simple>
	</moby:mobyData>
END

    return SOAP::Data->type('string' => (MOBY::CommonSubs::responseHeader('cnio.es') . $serviceRequest . MOBY::CommonSubs::responseFooter()));

#      return $serviceRequest;
};

# This variable is a subroutine which carry out the core of the service
my $serviceTwo = sub {
   my ( $caller, $MOBY_message ) = @_;


     # ...
     # The code of your service
     # ...
   sleep(10);
   my $serviceRequest = <<END;
	<moby:mobyData queryID="1">
        	<moby:Simple moby:articleName="serviceTwo">
			<moby:Object id="" namespace="" articleName="" /> 
		</moby:Simple>
	</moby:mobyData>
END

    return SOAP::Data->type('string' => (MOBY::CommonSubs::responseHeader('cnio.es') . $serviceRequest . MOBY::CommonSubs::responseFooter()));

#      return $serviceRequest;
};

# This is the method that answers to synchronous requests
sub serviceOne {
    my $self=shift @_;
    #my ( $caller, $MOBY_message ) = @_;

    # Here you can choose between sync or error
    #return $self->sync($serviceOne, 180, @_);
    return $self->error(@_);
}

# This is the method that answers to synchronous requests
sub serviceTwo {
    my $self=shift @_;
    #my ( $caller, $MOBY_message ) = @_;

    # Here you can choose between sync or error
    #return $self->sync($serviceTwo, 180, @_);
    return $self->error(@_);
}

# This is the method that answers to asynchronous requests
sub serviceOne_submit {
     my $self = shift @_;
     return $self->async($serviceOne, @_);
}

# This is the method that answers to asynchronous requests
sub serviceTwo_submit {
     my $self = shift @_;
     return $self->async($serviceTwo, @_);
}

1;
                                                                         
