Basic Security using sample php

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Basic Security using sample php

Jento Arakkal

Hi,

 

I have been trying to implement the basic php ws-security example shown here: http://wso2.org/project/wsf/php/2.0.0/docs/manual.html

 

Client:

 

try {

               

                                                $policy = new WSPolicy(array("security" => array("useUsernameToken" => TRUE,

                                                                                                 "includeTimeStamp" => TRUE)));

 

                                                $sec_token = new WSSecurityToken(array("user" => "bob",

                                                                                                                                "password" => "bob12",

                                                                                                                "passwordType" => "Digest",

                                                                                                                "ttl" => 300));

                                               

$message = new WSMessage($reqestPayloadString,

                                                                                                array("to" => $web_service_loc));

                                               

                                                $client_props = array( "policy" => $policy,

                                                                                                 "securityToken " => $sec_token,

                                                                                                 "useWSA" => TRUE);

                                               

                                                $client = new WSClient($client_props);

 

                                                $response = $client->request($message);

                                                               

                                               

                                                return xml2array($response->str);

                                }

                                catch (Exception $e) {

                                                if ($e instanceof WSFault) {

            $fault = $e;

                                                                error_log("Soap Fault received with code '%s' and reason '%s'\n" .

                    $fault->reason . ", " . $fault->reason);

                                                                printf("Soap Fault received with code '%s' and reason '%s'\n",

                    $fault->code, $fault->reason);

                                                }

                                                else {

                                                                error_log($web_service_loc.":: Exception caught with message '%s' ". $e->getMessage() . ". Request '".$request."', Query " . $item_query);

            printf("Exception caught with message '%s'\n", $e->getMessage() . ". Request '".$request."', Query " . $item_query);

                                                }       

                                }

 

Service:

 

function greet1($message) {

 

$responsePayloadString = <<<XML

        <greetResponse>Hello Client1!</greetResponse>

XML;

 

        $returnMessage = new WSMessage($responsePayloadString);

 

        return $returnMessage;

}

 

 

//$service = new WSService(array("operations" => array("greet1","getItemData")));

 

$policy = new WSPolicy(array("security" => array("useUsernameToken" => TRUE,

                                                 "includeTimeStamp" => TRUE)));

 

$sec_token = new WSSecurityToken(array("user" => "bob",

                                        "password" => "bob11",

                                        "passwordType" => "Digest",

                                        "ttl" => 100));

 

$service = new WSService(array("operations" => array("greet1"),"policy" => $policy,"securityToken" => $sec_token));

 

$service->reply();

 

I am repeatedly get Exception with no response or  the error “Soap Fault received with code '%s' and reason '%s', PHP Fatal error:  Cannot access protected property WSFault::$code in ws.php on line 304

 

Any help is much appreciated.

 

Jento Arakkal,

 


_______________________________________________
Wsf-php-user mailing list
[hidden email]
https://wso2.org/cgi-bin/mailman/listinfo/wsf-php-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Basic Security using sample php

Nandika Jayawardana
What is the wsf/php version you are trying. In wsf/php 2.1.0, by
default, it required keys for signing as well. You can avoid this by
using a policy file.

Regards
Nandika

On Thu, May 19, 2011 at 10:45 AM, Jento Arakkal <[hidden email]> wrote:

> Hi,
>
>
>
> I have been trying to implement the basic php ws-security example shown
> here: http://wso2.org/project/wsf/php/2.0.0/docs/manual.html
>
>
>
> Client:
>
>
>
> try {
>
>
>
>                                                 $policy = new
> WSPolicy(array("security" => array("useUsernameToken" => TRUE,
>
>
>                                                  "includeTimeStamp" =>
> TRUE)));
>
>
>
>                                                 $sec_token = new
> WSSecurityToken(array("user" => "bob",
>
>
>
> "password" => "bob12",
>
>
>
> "passwordType" => "Digest",
>
>
>                                                                 "ttl" =>
> 300));
>
>
>
> $message = new WSMessage($reqestPayloadString,
>
>
> array("to" => $web_service_loc));
>
>
>
>                                                 $client_props = array(
> "policy" => $policy,
>
>
>                                                  "securityToken " =>
> $sec_token,
>
>
>                                                  "useWSA" => TRUE);
>
>
>
>                                                 $client = new
> WSClient($client_props);
>
>
>
>                                                 $response =
> $client->request($message);
>
>
>
>
>
>                                                 return
> xml2array($response->str);
>
>                                 }
>
>                                 catch (Exception $e) {
>
>                                                 if ($e instanceof WSFault) {
>
>             $fault = $e;
>
>
> error_log("Soap Fault received with code '%s' and reason '%s'\n" .
>
>                     $fault->reason . ", " . $fault->reason);
>
>                                                                 printf("Soap
> Fault received with code '%s' and reason '%s'\n",
>
>                     $fault->code, $fault->reason);
>
>                                                 }
>
>                                                 else {
>
>
> error_log($web_service_loc.":: Exception caught with message '%s' ".
> $e->getMessage() . ". Request '".$request."', Query " . $item_query);
>
>             printf("Exception caught with message '%s'\n", $e->getMessage()
> . ". Request '".$request."', Query " . $item_query);
>
>                                                 }
>
>                                 }
>
>
>
> Service:
>
>
>
> function greet1($message) {
>
>
>
> $responsePayloadString = <<<XML
>
>         <greetResponse>Hello Client1!</greetResponse>
>
> XML;
>
>
>
>         $returnMessage = new WSMessage($responsePayloadString);
>
>
>
>         return $returnMessage;
>
> }
>
>
>
>
>
> //$service = new WSService(array("operations" =>
> array("greet1","getItemData")));
>
>
>
> $policy = new WSPolicy(array("security" => array("useUsernameToken" => TRUE,
>
>                                                  "includeTimeStamp" =>
> TRUE)));
>
>
>
> $sec_token = new WSSecurityToken(array("user" => "bob",
>
>                                         "password" => "bob11",
>
>                                         "passwordType" => "Digest",
>
>                                         "ttl" => 100));
>
>
>
> $service = new WSService(array("operations" => array("greet1"),"policy" =>
> $policy,"securityToken" => $sec_token));
>
>
>
> $service->reply();
>
>
>
> I am repeatedly get Exception with no response or  the error “Soap Fault
> received with code '%s' and reason '%s', PHP Fatal error:  Cannot access
> protected property WSFault::$code in ws.php on line 304
>
>
>
> Any help is much appreciated.
>
>
>
> Jento Arakkal,
>
>
>
> _______________________________________________
> Wsf-php-user mailing list
> [hidden email]
> https://wso2.org/cgi-bin/mailman/listinfo/wsf-php-user
>
>



--
Nandika Jayawardana
Technical Lead and Project Manager,
WSO2 Inc ; http://wso2.com
lean.enterprise.middleware
_______________________________________________
Wsf-php-user mailing list
[hidden email]
https://wso2.org/cgi-bin/mailman/listinfo/wsf-php-user
Loading...