简单的PHP肥皂请求

时间:2013-12-13 11:12:24

标签: php soap

我做了非常简单的测试请求。有我的文件:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://localhost/webshop">
   <soap:Header/>
   <soap:Body>
      <web:TestRequest/>
   </soap:Body>
</soap:Envelope>

这是我的要求:

$uri = '...';
$login = '...';
$pass = '...';
try{
 $client = new SoapClient($uri, Array('login' => $login, 'password' => $pass));
}catch(SoapFault $exception){
 $errors[] = 'Error: '.$exception;
}
//print_r($errors); //empty


if($client){
  $param = array();
  //var_dump($client);
  //var_dump($client->__getFunctions());
  $result = $client->__doRequest('TestRequest', $param);
  //$result = $client->TestRequest();
  var_dump($result); //return NULL
    echo "<br>";
  var_dump("REQUEST=", $client->__getLastRequest()); //return string(7) "REQUEST" NULL 
  var_dump("RESPONSE=", $client->__getLastResponse());//return string(8) "RESPONSE" NULL
}

它是否可以返回NULL?或者我做错了什么!?

谢谢!

1 个答案:

答案 0 :(得分:0)

您在 __doRequest() 上缺少操作参数。请参阅here

应该是..

$result = $client->__doRequest('web:TestRequest', $param, $action, $version);
                                                          ----^--- ----^----