Monday, January 14, 2008

Using WS-Reliable Messaging with PHP

Once you have configured WSF/PHP, you can use WS-RM for client side by adding a couple of options to the WSClient options array as follows.

$wsclient = new WSClient(array("reliable" => TRUE , "useWSA" => TRUE));

Note how I have set "reliable" options to TRUE.

Also note how the WS-Addressing is enabled by specifing the option useWSA=>TRUE.

Now your client is configured to use WS-Reliable Messaging.

Next create a massage to be sent.

$requestMessage = new WSMessage($requestPayloadString,
array( "to" => "http://test.com/rm_service",
"action" => "http://test.com/services/pingStringRM"));


$requestPayloadString is the xml payload to be sent to the destination.
"action" is the WS-Addressing action. Note that this is a must for WS-RM to work.

Now we can use the client object and send the message to the destination with WS-RM on using the send method as follows.

$client->send($requestMessage);

This becomes a one way message since we are using the send method.

I will discuss WS-RM in more detail in the next few days.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. $url = "https://testws.acep.org/ISV/ACEP/Services/SSO/AcepSSOService.svc";

    $requestPayloadString = '




    hjo20s55mfvstnetzrllcv55A608718


    ';

    $wsclient = new WSClient(array("reliable" => 1.1 , "useWSA" => TRUE));
    $requestMessage = new WSMessage($requestPayloadString,array( "to" => $url,"action" => "https://testws.acep.org/ISV/ACEP/Services/SSO/AcepSSOService.svc/GetContactDetailsFromWebSessionID"));
    try {
    $responseMessage = $wsclient->request($requestMessage);
    print_r($responseMessage);die();
    printf("Response = %s \n", htmlspecialchars($responseMessage->str));

    } catch (Exception $e) {

    if ($e instanceof WSFault) {
    printf("Soap Fault : %s\n", $e->Reason);
    } else {
    printf("Message = %s\n",$e->getMessage());
    }

    }

    I checked with the error log. It shows errors like:

    [Thu Oct 4 17:53:39 2012] [info] Cannot find path /usr/lib64/php/modules/wsf_c/services.
    [Thu Oct 4 17:53:39 2012] [info] [rampart] rampart_mod initialized
    [Thu Oct 4 17:53:39 2012] [info] [rahas]Rahas module initialized
    [Thu Oct 4 17:53:39 2012] [error] sandesha2_utils.c(1501) [sandesha][sandesha_util] Policy is NULL.
    [Thu Oct 4 17:53:39 2012] [error] sandesha2_utils.c(248) [sandesha2] Cannot Retreive RM assertion
    [Thu Oct 4 17:53:39 2012] [error] sandesha2_utils.c(1501) [sandesha][sandesha_util] Policy is NULL.
    [Thu Oct 4 17:53:39 2012] [error] sandesha2_utils.c(248) [sandesha2] Cannot Retreive RM assertion
    [Thu Oct 4 17:53:39 2012] [error] app_msg_processor.c(1590) [sandesha2] Could not send create sequence message


    I am really stuck on this, I will be really thankful if you can help me

    ReplyDelete
  3. Actually, we removed the reliable messaging support from WSF/PHP for later implementations. Hence reliable syntax will not work.

    Regards
    Nandika

    ReplyDelete