0

我正在尝试建立与 java-server 的连接。这是php代码:

<?php   

$GLOBALS['THRIFT_ROOT'] = 'root';  
/*Remember these two files? */  
require_once 'Types.php';  
require_once 'MachineControl.php';  
/* Dependencies. In the proper order. */  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Transport/TTransport.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Transport/TSocket.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Exception/TException.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Exception/TApplicationException.php'; 
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Base/TBase.php'; 
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Protocol/TProtocol.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Protocol/TBinaryProtocol.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Transport/TBufferedTransport.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Type/TMessageType.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Factory/TStringFuncFactory.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/StringFunc/TStringFunc.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/StringFunc/Core.php';  
require_once $GLOBALS['THRIFT_ROOT'].'/Thrift/Type/TType.php';  
use Thrift\Protocol\TBinaryProtocol;  
use Thrift\Transport\TSocket;  
use Thrift\Transport\TSocketPool;  
use Thrift\Transport\TFramedTransport;  
use Thrift\Transport\TBufferedTransport;  
$host = '192.168.129.117';  
$port = 9090;  
$socket = new Thrift\Transport\TSocket($host, $port);  
$transport = new TBufferedTransport($socket);  
$protocol = new TBinaryProtocol($transport);  
 // Create a calculator client  
$client = new MachineControlClient($protocol);  
$transport->open();  
echo "Eror: " . $client ->getError(); ?>

我与 java-server 有连接。但我在 test.php 文件中的输出将是:

Fatal error: Uncaught exception 'Thrift\Exception\TApplicationException' with message 'Internal error processing getError' in C:\xampp\htdocs\jasa\thrift\MachineControl.php:877 Stack trace: #0 C:\xampp\htdocs\jasa\thrift\MachineControl.php(845): MachineControlClient->recv_getError() #1 C:\xampp\htdocs\jasa\thrift\test.php(34): MachineControlClient->getError() #2 {main} thrown in C:\xampp\htdocs\jasa\thrift\MachineControl.php on line 877

出了什么问题?所有文件和类都在文件中,getError 类如下所示:

    public function getError()
  {
    $this->send_getError();
    return $this->recv_getError();
  }

  public function send_getError()
  {
    $args = new \MachineControl_getError_args();
    $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary');
    if ($bin_accel)
    {
      thrift_protocol_write_binary($this->output_, 'getError', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
    }
    else
    {
      $this->output_->writeMessageBegin('getError', TMessageType::CALL, $this->seqid_);
      $args->write($this->output_);
      $this->output_->writeMessageEnd();
      $this->output_->getTransport()->flush();
    }
  }

  public function recv_getError()
  {
    $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary');
    if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\MachineControl_getError_result', $this->input_->isStrictRead());
    else
    {
      $rseqid = 0;
      $fname = null;
      $mtype = 0;

      $this->input_->readMessageBegin($fname, $mtype, $rseqid);
      if ($mtype == TMessageType::EXCEPTION) {
        $x = new TApplicationException();
        $x->read($this->input_);
        $this->input_->readMessageEnd();
        throw $x;
      }
      $result = new \MachineControl_getError_result();
      $result->read($this->input_);
      $this->input_->readMessageEnd();
    }
    if ($result->success !== null) {
      return $result->success;
    }
    throw new \Exception("getError failed: unknown result");
  }

非常感谢您抽出时间讨论这个问题;)

4

1 回答 1

0

服务器出现问题,此主题将被关闭

于 2013-08-29T08:58:21.313 回答