【问题标题】:PHP NuSOAP Web Service ErrorPHP NuSOAP Web 服务错误
【发布时间】:2015-01-29 23:42:21
【问题描述】:

我有一个带有 NuSOAP 的 PHP Web 服务,我有一个复杂的类型,然后与堆栈上的另一个帖子相同,见下文:

#SERVER    
$server->wsdl->addComplexType('User',
'complexType','struct', 'all', '',
array(  'id' => array('name' => 'id', 'type' => 'xsd:int'),
    'username' => array('name' => 'username','type' => 'xsd:string'),
    'password' => array('name' => 'password','type' => 'xsd:string'),
    'email' => array('name' => 'email','type' => 'xsd:string'),
    'authority' => array('name' => 'authority','type' => 'xsd:int'),
    'isActive' => array('name' => 'isActive','type' => 'xsd:int'),
    'area' => array('name' => 'area','type' => 'xsd:string')
)
);
$server->register('ws_getUser',
    array('user_id' => 'xsd:integer'),
    array('user' =>  'tns:User'),
    $namespace,
    "$namespace#ws_getUser",
    'rpc',
    'encoded',
    'Retorna un usuario'
);

function ws_getUser($user_id){
    return new soapval('return', 'tns:User', getUser($user_id));
}

#CLIENT
require_once('./classes/nusoaplib/nusoap.php');
$client = new soapclient('http://localhost/api.php?wsdl');
$result = $client->__call('ws_getUser', array('id' => '1', 'username' => 'user', 'password' => 'pass', 'email' => 'user@email.co.za', 'authority' => '1', 'isActive' => '1', 'area' => 'usa'));

// Display the result
var_dump($result);

但是我不断收到来自服务的错误,我尝试了很多不同类型的复杂类型更改,但仍然收到相同的错误。

错误

致命错误:未捕获的 SoapFault 异常:[客户端] 看起来我们在 C:\wamp\www\api.php:26 中没有 XML 文档 堆栈跟踪:#0 C:\wamp\www\api.php(26 ): SoapClient->__call('ws_getUser', Array) #1 {main} 在第 26 行的 C:\wamp\www\api.php 中抛出

我在 PHP 5.4.3 和 Nusoap 库 0.9.5 中使用 wamp 如果有人能告诉我问题是什么 谢谢

【问题讨论】:

    标签: php service web nusoap


    【解决方案1】:

    我使用 wamp 解决了这个问题,我启用了 soap 扩展,每次我注册客户端或服务器时,它都会找到默认 soap 而不是 nusoap 的类

    正确 $client = new nusoap_client('http://localhost/nusoap/server.php?wsdl'); 不正确 $client = new soapclient('http://localhost/nusoap/server.php?wsdl');

    与服务器相同。

    我收到的 php 错误是因为这个,而且它的格式不正确。普通soap ext将其作为stdClass返回。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多