How to setup Apache Thrift communication between a Java client and a PHP server?
I have PHP codes on server side:
$header('Content-Type', 'application/x-thrift');
$handler = new MyApplicationHandler();
$processor = new \tutorial\MyApplicationProcessor($handler);
$transport = new TFramedTransport(
new TPhpStream(TPhpStream::MODE_R | TPhpStream::MODE_W));
$protocol = new TBinaryProtocol($transport, true, true);
$transport->open();
$processor->process($protocol, $protocol);
$transport->close();
And Java codes on the client side:
THttpClient httpClient =
new THttpClient("http://my.application.com/PhpServer.php");
TTransport transport = new TFramedTransport(httpClient);
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
MyApplication.Client client = new MyApplication.Client(protocol);
Boolean result = client.someApi(someData); // <-- will crash here
transport.close();
The client will crash when executing this line:
client.someApi(someData);
Is there something wrong in my codes?