123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace tutorial\php;
- error_reporting(E_ALL);
- require_once("Config.inc.php");
- use Thrift\ClassLoader\ThriftClassLoader;
- use Thrift\Protocol\TBinaryProtocol;
- use Thrift\Transport\TSocket;
- use Thrift\Transport\THttpClient;
- use Thrift\Transport\TBufferedTransport;
- use Thrift\Exception\TException;
- use Thrift\Protocol\TMultiplexedProtocol;
- use OpenSearch\Generated\Common\Pageable;
- try {
- if (array_search('--http', $argv)) {
- $socket = new THttpClient('localhost', 8080, '/php/server.php');
- } else {
- $socket = new TSocket('localhost', 9090);
- }
- $transport = new TBufferedTransport($socket, 1024, 1024);
- $protocol = new TBinaryProtocol($transport);
- $transport->open();
- $clientProtocol = new TMultiplexedProtocol($protocol, 'openSearchServiceProcessor');
- $client = new \OpenSearch\Generated\OpenSearch\OpenSearchServiceClient($clientProtocol);
- $appProtocol = new TMultiplexedProtocol($protocol, 'appServiceProcessor');
- $appClient = new \OpenSearch\Generated\App\AppServiceClient($appProtocol);
-
- $ret = $appClient->save('test');
- print_r($ret);
- $transport->close();
- } catch (TException $tx) {
- print 'TException: '.$tx->getMessage()."\n";
- }
- ?>
|