简体   繁体   English

PHP NuSOAP Web服务错误

[英]PHP NuSOAP Web Service Error

I have a PHP web service with NuSOAP i have a complex type then same as another post on stack see below: 我有一个使用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);

But i keep getting errors from the service i have tried a lot of different type of changes to the complex type but keep getting the same errors. 但是我一直在从服务中获取错误,我已经尝试了对复杂类型进行许多不同类型的更改,但是仍然遇到相同的错误。

ERROR 错误

Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\\wamp\\www\\api.php:26 Stack trace: #0 C:\\wamp\\www\\api.php(26): SoapClient->__call('ws_getUser', Array) #1 {main} thrown in C:\\wamp\\www\\api.php on line 26 致命错误:未捕获的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中引发

Im using wamp with PHP 5.4.3 and Nusoap library 0.9.5 If anyone can tell me what the problem is Thanks 我在PHP 5.4.3和Nusoap库0.9.5中使用了wamp如果有人可以告诉我问题出在哪里,谢谢

I figured it out using wamp i enabled soap extensions and every time i registered the client or server it found the classes for the default soap instead of nusoap 我用启用了soap扩展的wamp弄清楚了,每次我注册客户端或服务器时,它都会找到默认soap而不是nusoap的类

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

same with the servers. 与服务器相同。

The php error i receive was because of this as well as it is not formatted in the correct way. 我收到的php错误是因为这个原因,以及它的格式不正确。 Normal soap ext returns it as a stdClass. 普通soap ext将其作为stdClass返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM