Example #1
0
#!/usr/local/bin/php
<?php 
$service = new PlutonService('getfault');
# Should fail as initialization has not been called
$rc = $service->getRequest();
print "Return from getRequest is {$rc}\n";
if ($service->hasFault()) {
    print "service has fault after missing initialize - good\n";
} else {
    print "service does NOT have fault after missing initialize - bad\n";
    #  exit(1);
}
$ftext = $service->getFault();
$fc = $service->getFaultCode();
$flong = $service->getFaultMessage("LONG", 1);
$fshort = $service->getFaultMessage("SHORT", 0);
print "Fault code={$fc} Text={$ftext}\n";
print "Short={$fshort}\n";
print "Long={$flong}\n";
if (strlen($flong) == 0) {
    print "Long message should not be zero length\n";
    exit(3);
}
if (strlen($fshort) == strlen($flong)) {
    print "Hmm expected short message to be shorter than long message\n";
    exit(4);
}
print "\n Service  getFault test ok\n";
Example #2
0
#!/usr/local/bin/php
<?php 
$service = new PlutonService('getstuff');
$service->initialize();
$service->getRequest();
$sk = $service->getServiceKey();
$sa = $service->getServiceApplication();
$sf = $service->getServiceFunction();
$sv = $service->getServiceVersion();
$serial = $service->getSerializationType();
$cn = $service->getClientName();
$service->sendResponse("sk={$sk} sa={$sa} sf={$sf} sv={$sv} serial={$serial} cn={$cn}\n");
$service->terminate();
# Give plTest a chance to consume the response
sleep(2);
exit(0);
Example #3
0
#!/usr/local/bin/php
<?php 
$service = new PlutonService('sendfault');
$service->initialize();
$service->getRequest();
$service->sendFault(11, 'sendResponse() failed');
$service->terminate();
exit(0);
Example #4
0
#!/usr/local/bin/php
<?php 
$service = new PlutonService('context');
$service->initialize();
$service->getRequest();
$ctx = $service->getContext("ctx");
$service->sendResponse($ctx);
$service->terminate();
# Give plTest a chance to consume the response
sleep(2);
exit(0);
Example #5
0
#!/usr/local/bin/php
<?php 
// Create and initialize the Pluton service.
$service = new PlutonService('simple');
$service->initialize();
$api = $service->getAPIVersion();
print "Service API Version: {$api}\n";
if (strlen($api) == 0) {
    print "Expected a non-zero length api version\n";
    exit(1);
}
// Invoke the call loop.
while ($service->getRequest()) {
    $request = $service->getRequestData();
    if (!$service->sendResponse($request)) {
        $service->sendFault(11, 'sendResponse() failed');
    }
}
if ($service->hasFault()) {
    error_log('Service had a fault');
}
$service->terminate();
print "Terminate complete - about to exit\n";
exit(0);