首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >网站服务的NuSOAP帮助

网站服务的NuSOAP帮助
EN

Stack Overflow用户
提问于 2010-11-18 09:58:16
回答 2查看 5.5K关注 0票数 4

我正在尝试用NuSOAP做一个示例web服务,我构建了这个示例类:

代码语言:javascript
复制
<?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);
?>

客户端的这个类:

代码语言:javascript
复制
<?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);
?>

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

代码语言:javascript
复制
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,所有的文件都在正确的位置。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-09-04 03:35:46

使用NuSoap,因此需要调用nusoap_client :)

代码语言:javascript
复制
$client = new nusoap_client('http://localhost/webServiceResta.php');
票数 4
EN

Stack Overflow用户

发布于 2010-11-18 10:02:23

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

请参阅:http://www.w3.org/TR/wsdl#_wsdl

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4210964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档