PHP SoapClient:传递的对象在Java中以NULL形式接收

时间:2014-12-03 15:05:35

标签: java php wsdl long-integer soap-client

我做了一个php soap客户端。我在soapcall期间传递了一个复杂的对象和一个字符串。传递的对象在java中作为null接收,但传递的字符串被正确接收。类(userGPSDataVisulization)类具有long(userGPSDataId),int,float和string属性。是不是因为它是从java发送的简单整数和字符串而不是long和float?

class RetrieveUserGPSDataVisualization  {

public $userGPSDataVisulization;
public $StorageMedium='DATABASE';

function RetrieveUserGPSDataVisualization ($userGPSDataVisulization){

    $this->userGPSDataVisulization = $userGPSDataVisulization;
 }
}
class userGPSDataVisulization  {

    public $id=0;
    public $latitude=0.0;
    public $longitude=0.0;
    public $speed=0.0;
    public $timeStamp='';
    public $timeStampStart='';
    public $timeStampEnd='';
    public $userGPSDataId='0';
    public $userDeviceId='0';

function userGPSDataVisulization ($timeStampStart,$timeStampEnd){

    $this->timeStampStart = $timeStampStart;
    $this->timeStampEnd = $timeStampEnd;

}}
    $client = new SoapClient("http://localhost/etc/Layer?WSDL");

//setting dates
$useRGPSDataVisulization = new userGPSDataVisulization ('2014 12 01 00:00:00','2014 12 01 23:59:59');

//populate object
$RetrieveUserGPSDataVisualization=new RetrieveUserGPSDataVisualization($useRGPSDataVisulization);
$params = array(
 "RetrieveUserGPSDataVisualization" => $RetrieveUserGPSDataVisualization,
);

var_dump($params);

try{
$response = $client->__soapCall("RetrieveUserGPSDataVisualization", $params);
var_dump($response);
}
catch(Exception $e) {
  echo 'Message: ' .$e->getMessage();
}

通过调试我发现useRGPSDataVisulization对象在java中是空的,但是在php中调用soapcall之前它显示了所有的值。这是由于Java中的长数据类型吗?

由于

更新:我已解决此问题 我已经填充了这样的对象,并且对象没有收到NULL。这是调用soap函数的另一种方法。

$useRGPSDataVisulization = $client->RetrieveUserGPSDataVisualization($RetrieveUserGPSDataVisualization);

感谢所有回答和指导的人

2 个答案:

答案 0 :(得分:3)

尝试传入SOAP_ENC_OBJECT

$struct = new stdClass();
$struct->item1 = $item1; 

$response = $client->RetrieveUserGPSDataVisualization(new SoapVar($struct, SOAP_ENC_OBJECT));

答案 1 :(得分:2)

重命名以下内容:

function userGPSDataVisulization ($timeStampStart,$timeStampEnd){

要:

function __construct ($timeStampStart,$timeStampEnd){