【问题标题】:Help with NuSOAP for a Web Service用于 Web 服务的 NuSOAP 帮助
【发布时间】:2010-11-18 01:58:15
【问题描述】:

我正在尝试在 PHP 中使用 NuSOAP 做一个示例 Web 服务,并且我构建了这个示例类:

<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server;
// Register the method to expose
$server->register('hello');
// Define the method as a PHP function
function hello($name) {
    return 'Hello, ' . $name;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>

这个类用于客户端:

<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/webServiceResta.php');
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));
// Display the result
print_r($result);
?>

但是当我运行脚本时,我似乎得到了这个错误:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/webServiceResta.php' : Start tag expected, '<' not found in /opt/lampp/htdocs/prueba.php:5 Stack trace: #0 /opt/lampp/htdocs/prueba.php(5): SoapClient->SoapClient('http://localhos...') #1 {main} thrown in /opt/lampp/htdocs/prueba.php on line 5

我在 ubuntu 上使用 XAMPP,所有文件都在正确的位置。

【问题讨论】:

  • 是客户端代码,新版本改名为nusoap_client();

标签: php web-services xampp nusoap


【解决方案1】:

使用 NuSoap 所以你需要打电话给nusoap_client :)

$client = new nusoap_client('http://localhost/webServiceResta.php');

【讨论】:

    【解决方案2】:

    您发送的数据 (Hello,...) 不是正确的 XML,更不是正确的 SOAP WSDL 格式。

    见:http://www.w3.org/TR/wsdl#_wsdl

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 2015-04-21
      • 1970-01-01
      相关资源
      最近更新 更多