我在数据库中查询返回一个数组是用$array = pg_fetch_all($info);生成的,然后我把这个数组做为参数传给server,看debug信息能传过去,但是我不知道怎么读取和返回,每次返回都是null,请高手指定
服务器端程序:<?php
header("content-type:text/xml;charset=utf-8");
require_once("nusoap.php");
function concatenate($data) {
$data = $userDatas;
return $userDatas;
}
$soap = new soap_server();
$soap->configureWSDL('AuthorityServicewsdl', 'urn:AuthorityServicewsdl');
$soap->wsdl->schemaTargetNamespace = 'urn:AuthorityServicewsdl';
$soap->wsdl->addComplexType('userDatas','complexType','array','','SOAP-ENC:Array',
array(),
array(array('ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:tableData[]')),
'tns:userData');
$soap->wsdl->addComplexType('userData','complexType','struct','all','',
array(
'id' => array('name' => 'id', 'type' => 'xsd:string'),
'sku' => array('name' => 'sku', 'type' => 'xsd:string')
));
$soap->configureWSDL('concatenate'); $soap->register('concatenate',
array("data" => "xsd:array"), // input parameters
array("return"=>"xsd:userDatas")
); $HTTP_RAW_POST_DATA = file_get_contents("php://input");
//$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$soap->service($HTTP_RAW_POST_DATA);?>客户端程序:
$conn=pg_connect("host=192.168.1.122 dbname=postgres user=postgresql password=*****");
$sql="select id,sku from temp1 limit 10;";
$info=pg_exec($conn,$sql);
$array = pg_fetch_all($info);
$count = count($array);
$client = new nusoap_client('http://localhost/php_ws_test/s.php?wsdl',true);
$params1 = $array;
$str=$client->call('concatenate',$params1);
服务器端程序:<?php
header("content-type:text/xml;charset=utf-8");
require_once("nusoap.php");
function concatenate($data) {
$data = $userDatas;
return $userDatas;
}
$soap = new soap_server();
$soap->configureWSDL('AuthorityServicewsdl', 'urn:AuthorityServicewsdl');
$soap->wsdl->schemaTargetNamespace = 'urn:AuthorityServicewsdl';
$soap->wsdl->addComplexType('userDatas','complexType','array','','SOAP-ENC:Array',
array(),
array(array('ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:tableData[]')),
'tns:userData');
$soap->wsdl->addComplexType('userData','complexType','struct','all','',
array(
'id' => array('name' => 'id', 'type' => 'xsd:string'),
'sku' => array('name' => 'sku', 'type' => 'xsd:string')
));
$soap->configureWSDL('concatenate'); $soap->register('concatenate',
array("data" => "xsd:array"), // input parameters
array("return"=>"xsd:userDatas")
); $HTTP_RAW_POST_DATA = file_get_contents("php://input");
//$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$soap->service($HTTP_RAW_POST_DATA);?>客户端程序:
$conn=pg_connect("host=192.168.1.122 dbname=postgres user=postgresql password=*****");
$sql="select id,sku from temp1 limit 10;";
$info=pg_exec($conn,$sql);
$array = pg_fetch_all($info);
$count = count($array);
$client = new nusoap_client('http://localhost/php_ws_test/s.php?wsdl',true);
$params1 = $array;
$str=$client->call('concatenate',$params1);
搞得象网游样!
直接查看远程数据库就行了。
有一次让传递一个服务器端的类和对象的,不知如何传递