加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 帮助NuSOAP获取Web服务

发布时间:2020-12-13 17:05:06 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试用 PHP中的NuSOAP做一个示例Web服务,我构建了这个示例类: ?php// Pull in the NuSOAP coderequire_once('lib/nusoap.php');// Create the server instance$server = new soap_server;// Register the method to expose$server-register('hello');
我正在尝试用 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所以你需要调用nusoap_client

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读