This repository has been archived by the owner on Oct 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.wso2.org/repos/wso2/trunk/wsf@69092 a5903396-d…
…722-0410-b921-86c7d4935375
- Loading branch information
nandika
committed
Jul 4, 2010
1 parent
12cb5dc
commit 3b2fb6e
Showing
3 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
php/samples/security/signing/policy_file_based/wsdlmode/HelloClient.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
// PHP classes corresponding to the data types in defined in WSDL | ||
|
||
class greet { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $name; | ||
|
||
} | ||
|
||
class greetResponse { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $return; | ||
|
||
} | ||
|
||
// define the class map | ||
$class_map = array( | ||
"greet" => "greet", | ||
"greetResponse" => "greetResponse"); | ||
|
||
try { | ||
|
||
$my_cert = ws_get_cert_from_file("../../../keys/alice_cert.cert"); | ||
$my_key = ws_get_key_from_file("../../../keys/alice_key.pem"); | ||
$rec_cert = ws_get_cert_from_file("../../../keys/bob_cert.cert"); | ||
|
||
$sec_token = new WSSecurityToken(array("privateKey" => $my_key, | ||
"certificate" => $my_cert, | ||
"receiverCertificate" => $rec_cert)); | ||
|
||
$client = new WSClient(array ("wsdl" =>"HelloService.wsdl", | ||
"classmap" => $class_map, | ||
"useWSA"=>TRUE, | ||
"securityToken" => $sec_token)); | ||
|
||
$proxy = $client->getProxy(); | ||
|
||
$input = new greet(); | ||
$input->name = "Hello"; | ||
|
||
|
||
$response = $proxy->greet($input); | ||
echo $response->return; | ||
|
||
} catch (Exception $e) { | ||
// in case of an error, process the fault | ||
if ($e instanceof WSFault) { | ||
printf("Soap Fault: %s\n", $e->Reason); | ||
} else { | ||
printf("Message = %s\n", $e->getMessage()); | ||
} | ||
} | ||
?> |
66 changes: 66 additions & 0 deletions
66
php/samples/security/signing/policy_file_based/wsdlmode/HelloService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
// PHP classes corresponding to the data types in defined in WSDL | ||
|
||
class greet { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $name; | ||
|
||
} | ||
|
||
class greetResponse { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $return; | ||
|
||
} | ||
|
||
// define the class map | ||
$class_map = array( | ||
"greet" => "greet", | ||
"greetResponse" => "greetResponse"); | ||
|
||
// define PHP functions that maps to WSDL operations | ||
/** | ||
* Service function greet | ||
* @param object of greet $input | ||
* @return object of greetResponse | ||
*/ | ||
function greet($input) { | ||
$res = new greetResponse(); | ||
$res->return = "HelloWorld"; | ||
return $res; | ||
} | ||
|
||
|
||
// define the operations map | ||
$operations = array( | ||
"greet" => "greet"); | ||
|
||
// define the actions => operations map | ||
$actions = array( | ||
"urn:greet" => "greet"); | ||
|
||
$cert = ws_get_cert_from_file("../../../keys/bob_cert.cert"); | ||
$pvt_key = ws_get_key_from_file("../../../keys/bob_key.pem"); | ||
|
||
$sec_token = new WSSecurityToken(array("privateKey" => $pvt_key, | ||
"certificate" => $cert)); | ||
|
||
// create service in WSDL mode | ||
$service = new WSService(array ("wsdl" =>"HelloService.wsdl", | ||
"actions" => $actions, | ||
"useWSA"=>TRUE, | ||
"securityToken"=>$sec_token, | ||
"classmap" => $class_map, | ||
"operations" => $operations)); | ||
|
||
// process client requests and reply | ||
$service->reply(); | ||
|
||
?> |
100 changes: 100 additions & 0 deletions
100
php/samples/security/signing/policy_file_based/wsdlmode/HelloService.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://www.wso2.org/types" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://www.wso2.org/types"> | ||
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SgnOnlyAnonymous"> | ||
<wsp:ExactlyOne> | ||
<wsp:All> | ||
<sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> | ||
<wsp:Policy> | ||
<sp:InitiatorToken> | ||
<wsp:Policy> | ||
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> | ||
<wsp:Policy> | ||
<sp:WssX509V3Token10/> | ||
</wsp:Policy> | ||
</sp:X509Token> | ||
</wsp:Policy> | ||
</sp:InitiatorToken> | ||
<sp:RecipientToken> | ||
<wsp:Policy> | ||
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never"> | ||
<wsp:Policy> | ||
<sp:WssX509V3Token10/> | ||
</wsp:Policy> | ||
</sp:X509Token> | ||
</wsp:Policy> | ||
</sp:RecipientToken> | ||
<sp:AlgorithmSuite> | ||
<wsp:Policy> | ||
<sp:Basic256Rsa15/> | ||
</wsp:Policy> | ||
</sp:AlgorithmSuite> | ||
<sp:Layout> | ||
<wsp:Policy> | ||
<sp:Strict/> | ||
</wsp:Policy> | ||
</sp:Layout> | ||
</wsp:Policy> | ||
</sp:AsymmetricBinding> | ||
<sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> | ||
<wsp:Policy> | ||
<sp:MustSupportRefKeyIdentifier/> | ||
<sp:MustSupportRefEmbeddedToken/> | ||
<sp:MustSupportRefIssuerSerial/> | ||
</wsp:Policy> | ||
</sp:Wss10> | ||
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> | ||
<sp:Body/> | ||
<sp:Header Namespace="http://www.w3.org/2005/08/addressing"/> | ||
</sp:SignedParts> | ||
</wsp:All> | ||
</wsp:ExactlyOne> | ||
</wsp:Policy> | ||
<wsdl:documentation>HelloService</wsdl:documentation> | ||
<wsdl:types> | ||
<xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://www.wso2.org/types"> | ||
<xs:element name="greet"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
<xs:element name="greetResponse"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string" /> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:schema> | ||
</wsdl:types> | ||
<wsdl:message name="greetRequest"> | ||
<wsdl:part name="parameters" element="ns:greet" /> | ||
</wsdl:message> | ||
<wsdl:message name="greetResponse"> | ||
<wsdl:part name="parameters" element="ns:greetResponse" /> | ||
</wsdl:message> | ||
<wsdl:portType name="HelloServicePortType"> | ||
<wsdl:operation name="greet"> | ||
<wsdl:input message="ns:greetRequest" wsaw:Action="urn:greet" /> | ||
<wsdl:output message="ns:greetResponse" wsaw:Action="urn:greetResponse" /> | ||
</wsdl:operation> | ||
</wsdl:portType> | ||
<wsdl:binding name="HelloServiceSoap12Binding" type="ns:HelloServicePortType"> | ||
<wsp:PolicyReference xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" URI="#SgnOnlyAnonymous" /> | ||
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> | ||
<wsdl:operation name="greet"> | ||
<soap12:operation soapAction="urn:greet" style="document" /> | ||
<wsdl:input> | ||
<soap12:body use="literal" /> | ||
</wsdl:input> | ||
<wsdl:output> | ||
<soap12:body use="literal" /> | ||
</wsdl:output> | ||
</wsdl:operation> | ||
</wsdl:binding> | ||
<wsdl:service name="HelloService"> | ||
<wsdl:port name="HelloServiceHttpSoap12Endpoint" binding="ns:HelloServiceSoap12Binding"> | ||
<soap12:address location="http://localhost/samples/security/signing/policy_file_based/wsdlmode/HelloService.php" /> | ||
</wsdl:port> | ||
</wsdl:service> | ||
</wsdl:definitions> |