[英]PHP NuSOAP Web Service Error
我有一個使用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如果有人可以告訴我問題出在哪里,謝謝
我用啟用了soap擴展的wamp弄清楚了,每次我注冊客戶端或服務器時,它都會找到默認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返回。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.