9. Reliable Messaging Manual

The WSO2 WSF/Perl extension supports reliable messaging (RM) protocol versions 1.0 and 1.1.

9.1. Writing RM Enabled Client.

Since WS-Addressing is required for WS-RM to work, you need to specify the necessary WS-Addressing options along with RM Options. Let's implement a simple RM client with WSO2 WSF/Perl.

First create a suitable payload to be sent to the echo service.

my $payload = '
<ns1:echoString xmlns:ns1="http://tempuri.org/">
  <ns1:Text>echo1</ns1:Text>
</ns1:echoString>
'
;

my $msg = new WSO2::WSF::WSMessage( { 'action' => 'http://php.axis2.org/samples/echoString',
                                      'payload' => $payload
                                    } );

my $client = new WSO2::WSF::WSClient(
    { 'to' => 'http://localhost:8585/axis2/services/RMSampleService',
      'reliable' => 'TRUE'
    } );

Note that we set the addressing action in WSMessage options and "reliable" option to "true" in WSClient options to enable RM. When the WS-Addressing action is present and the option "reliable" is set to "true", addressing will be enabled automatically. This client will create an RM Sequence, send its application message and terminate the sequence.

If you wish to send multiple application messages reliably to the receiving RM endpoint, you can configure the above Web service client as follows.

my $message = new WSO2::WSF::WSMessage(
    { 'to'      => 'http://localhost:8585/axis2/services/RMSampleService',
      'action'  => 'http://php.axis2.org/samples/echoString',
      'payload' => $payload
    } );

my $message1 = new WSO2::WSF::WSMessage(
    { 'to'      => 'http://localhost:8585/axis2/services/RMSampleService',
      'action'  => 'http://php.axis2.org/samples/echoString',
      'payload' => $payload
    } );

my $message2 = new WSO2::WSF::WSMessage(
    { 'to'           => 'http://localhost:8585/axis2/services/RMSampleService',
      'action'       => 'http://php.axis2.org/samples/echoString',
      'last_message' => 'TRUE',
      'payload'      => $payload
    } );

my $client = new WSO2::WSF::WSClient(
    { 'reliable'               => 'TRUE',
      'useWSA'                 => 'TRUE',
      'will_continue_sequence' => 'TRUE'
    } );

$client->request( $message );
$client->request( $message1 );
$client->request( $message2 );

Since we specified "willContinueSequence" option to "true" in WSClient , it will not terminate the sequence after sending the first message. It keeps the sequence open till the default "Sequence ExpiryTime" expires. You can configure this value using the "sequenceExpiryTime" option in WSClient. So we send the msg2 using the currently opened sequence. On msg3 we specify that this will be the last message that will be sent using the current sequence using the option "lastMessage" set to "true". Now WSClient will terminate the current sequence after sending msg3.