首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nusoap简单服务器

nusoap简单服务器
EN

Stack Overflow用户
提问于 2012-02-03 22:24:24
回答 3查看 49.4K关注 0票数 11

您好,我正在为nusoap服务器使用此代码,但当我在web浏览器中调用服务器时,它显示消息"This service is not provide a Web description“以下是代码

代码语言:javascript
复制
<?
//call library
require_once ('lib/nusoap.php');

//using soap_server to create server object
$server = new soap_server;

//register a function that works on server
$server->register('hello');

// create the function
function hello($name)
{
if(!$name){
return new soap_fault('Client','','Put your name!');
}

$result = "Hello, ".$name;
return $result;
}

// create HTTP listener
$server->service($HTTP_RAW_POST_DATA);

exit();
?>

一个帮助..。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-02-03 22:39:52

请将您的代码更改为

代码语言:javascript
复制
<?php
//call library
require_once('nusoap.php');
$URL       = "www.test.com";
$namespace = $URL . '?wsdl';
//using soap_server to create server object
$server    = new soap_server;
$server->configureWSDL('hellotesting', $namespace);

//register a function that works on server
$server->register('hello');

// create the function
function hello($name)
{
    if (!$name) {
        return new soap_fault('Client', '', 'Put your name!');
    }
    $result = "Hello, " . $name;
    return $result;
}
// create HTTP listener
$server->service($HTTP_RAW_POST_DATA);
exit();
?>

您没有定义命名空间..

请看这里的简单示例:-

http://patelmilap.wordpress.com/2011/09/01/soap-simple-object-access-protocol/

票数 18
EN

Stack Overflow用户

发布于 2012-02-03 22:32:37

web浏览器没有调用Web服务-您可以创建一个PHP客户端:

代码语言:javascript
复制
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$client = new soapclient('your server url');
// Call the SOAP method
$result = $client->call('hello', array('name' => 'StackOverFlow'));
// Display the result
print_r($result);

这应该会显示Hello, StackOverFlow

更新

要创建WSDL,您需要添加以下内容:

代码语言:javascript
复制
$server->configureWSDL(<webservicename>, <namespace>);
票数 5
EN

Stack Overflow用户

发布于 2012-05-18 13:29:14

您也可以使用nusoap_client

代码语言:javascript
复制
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$client = new nusoap_client('your server url'); // using nosoap_client
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Pingu'));
// Display the result
print_r($result)
?>
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9130117

复制
相关文章

相似问题

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