2013-12-16 134 views
1

我是wsdl,nusoap代碼的新手。我正在嘗試使用Nousoap來實現一個簡單的hello world編程。我在wsdl_hello_server.php實現服務器代碼,Nusap代碼無法正常工作

<?php 

require_once('nusoap.php'); 
    $server = new soap_server(); 
    $server->register('hello'); 

function hello($name) { 
    return 'Hello, ' . $name; 
} 

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; 
$server->service($HTTP_RAW_POST_DATA); 

?> 

和客戶端代碼保存在文件wsdl_hello_client.php

<?php 

require_once('nusoap.php'); 


$client = new soapclient('http://localhost:8888/nousoap_example/wsdl_hello_server.php'); 



$result = $client->call('hello', array('name' => 'world')); 


print_r($result); 
?> 

當我運行客戶端它不會給任何結果(空白頁)。如果我嘗試運行服務器代碼,它給我,

<SO`AP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP-ENV:Body> 
     <SOAP-ENV:Fault> 
      <faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode> 
      <faultactor xsi:type="xsd:string"/> 
       <faultstring xsi:type="xsd:string">method '' not defined in service</faultstring> 
       <detail xsi:type="xsd:string"/> 
     </SOAP-ENV:Fault> 
     </SOAP-ENV:Body> 
    </SOAP-ENV:Envelope>` 

忘記somthing?請幫幫我 ??

注:我已經包含在同一文件夾 'nusoap.php'

回答

0

我的猜測是$ HTTP_RAW_POST_DATA未設置;因此您將''發送給您的$server->service()''不是現有功能。嘗試調試$ HTTP_RAW_POST_DATA。

你也可以通過添加調試客戶端和服務器:

// Display the request and response 
echo '<h2>Request</h2>'; 
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; 
echo '<h2>Response</h2>'; 
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>'; 

正如從你可能已經從所採取的非常過時的例子頁面。

0

您可以嘗試添加WSDL在諸如URL的末尾:?

$client = new soapclient('http://localhost:8888/nousoap_example/wsdl_hello_server.php?wsdl'); 
+0

仍然不能工作:( – omrehman