SELAMAT DATANG DI BLOG KAMI .....

Monday 17 September 2012

Koding Web Service

Koding Untuk Membuat "test_client"

<?php
$requestPayloadString = <<<XML
<ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples"><text>Praktikum IAK</text></ns1:echoString>
XML;

try {

    $client = new WSClient(array("to"=>"http://localhost/test_server.php"));

    $responseMessage = $client->request($requestPayloadString);

    printf("Response = %s <br>", htmlspecialchars($responseMessage->str));

} catch (Exception $e) {

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

}
?>

Untuk Membuat "test_server"

<?php
$requestPayloadString = <<<XML
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Header/>
   <soapenv:Body>
     <ns1:echoString xmlns:ns1="http://wso2.org/wsfphp/samples">
         <text>Hello World!</text>
     </ns1:echoString>
    </soapenv:Body>
</soapenv:Envelope>
XML;

function echoFunction($inMessage) {
    $outMessage = new WSMessage($inMessage->str);
    return $outMessage;
}

$operations = array("echoString" => "echoFunction");

$service = new WSService(array("operations" => $operations));
       
$service->reply($requestPayloadString);

?>



sumber : Localhost Sample

0 comments:

Post a Comment