服务器 apache 的问题 - nusoap php
当我在服务器上部署代码时。 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为“<”和“>”在 XML 中用于表示字段,您应该在调用中以某种方式转义它们:
注意:我还没有对此进行测试,因此不能保证这是正确的
As "<" and ">" are used within XML to signify fields, you should escape them in some way in the call:
NB: I've not tested this so cannot guarantee that this is correct