2011-10-05 27 views
0

当我在服务器上部署代码。 问题的的NuSOAP:习题与服务器的Apache - 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”。

数据返回删除 “<” “>”。这个问题。请帮忙!

+0

我只是雇员复制粘贴此,并尝试将其传递给我的工作代码!!!! – Rob

回答

0

为“<”和“>”的XML中用来表示字段,您应该逃避他们以某种方式在呼叫:

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

注:我没有测试,所以不能保证这是正确的

+0

不行,谢谢 –