服务器 apache 的问题 - nusoap php

发布于 2024-12-08 17:02:37 字数 1298 浏览 1 评论 0原文

当我在服务器上部署代码时。 nusoap 的问题:

服务器代码:

    <?php
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server();
$server->configureWSDL('WS_WITH_SMS',NS);
$server->wsdl->schemaTargetNamespace=NS;
// Register the method to expose

function hello($name) {

    return $name;
}

function process_name($function_name,$param)
{   
    if(function_exists($function_name)) 
    {   
        return $function_name($param);
    }
    else
        return 'ERROR_TRANSMISSION|'.ERROR_TRANSMISSION;
}
// Define the method as a PHP function

$server->register('process_name',array('function_name'=>'xsd:string','param'=>'xsd:string'),array('result'=>'xsd:string'),NS);

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = (isset($HTTP_RAW_POST_DATA)) ? $HTTP_RAW_POST_DATA :'';
$server->service($GLOBALS['HTTP_RAW_POST_DATA']);
?>

客户端代码:

require_once 'lib/nusoap.php';
$url_ws = 'http://server/testnusoap/server.php?wsdl';
$soapClient = new nusoapclient($url_ws,'wsdl');
$result = $soapClient->call('process_name',array('function_name'=>'hello','param'=>"<aa>" ));
var_dump($result);

=>数据返回客户端“aa”。

数据返回去掉了“<” “>”。这个问题。请帮忙!

When i deploy code on server.
Problem with nusoap:

Server code:

    <?php
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server();
$server->configureWSDL('WS_WITH_SMS',NS);
$server->wsdl->schemaTargetNamespace=NS;
// Register the method to expose

function hello($name) {

    return $name;
}

function process_name($function_name,$param)
{   
    if(function_exists($function_name)) 
    {   
        return $function_name($param);
    }
    else
        return 'ERROR_TRANSMISSION|'.ERROR_TRANSMISSION;
}
// Define the method as a PHP function

$server->register('process_name',array('function_name'=>'xsd:string','param'=>'xsd:string'),array('result'=>'xsd:string'),NS);

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = (isset($HTTP_RAW_POST_DATA)) ? $HTTP_RAW_POST_DATA :'';
$server->service($GLOBALS['HTTP_RAW_POST_DATA']);
?>

Client code:

require_once 'lib/nusoap.php';
$url_ws = 'http://server/testnusoap/server.php?wsdl';
$soapClient = new nusoapclient($url_ws,'wsdl');
$result = $soapClient->call('process_name',array('function_name'=>'hello','param'=>"<aa>" ));
var_dump($result);

=> data return client "aa".

Data return removed "<" ">". This ploblem. Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

标点 2024-12-15 17:02:37

作为“<”和“>”在 XML 中用于表示字段,您应该在调用中以某种方式转义它们:

$result = $soapClient->call(
    'process_name',
    array(
        'function_name'=>'hello',
        'param'=>"\<aa\>"
    )
);

注意:我还没有对此进行测试,因此不能保证这是正确的

As "<" and ">" are used within XML to signify fields, you should escape them in some way in the call:

$result = $soapClient->call(
    'process_name',
    array(
        'function_name'=>'hello',
        'param'=>"\<aa\>"
    )
);

NB: I've not tested this so cannot guarantee that this is correct

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文