用服务器apache的问题 - nusoap php

时间:2011-10-05 14:33:07

标签: php nusoap

当我在服务器上部署代码时。 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);

=&GT;数据返回客户端“aa”。

删除了数据“&lt;” “&gt;” 中。这个问题。请帮忙!

1 个答案:

答案 0 :(得分:0)

As“&lt;”和“&gt;”在XML中用于表示字段,您应该在调用中以某种方式转义它们:

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

注意:我没有测试过,所以无法保证这是正确的