20,359
社区成员
发帖
与我相关
我的任务
分享
<?php
require_once("lib/nusoap.php");
$server = new soap_server;
//避免乱码
$server->soap_defencoding = 'UTF-8';
$server->decode_utf8 = false;
$server->xml_encoding = 'UTF-8';
$server->configureWSDL('sayHello');//打开wsdl支持
/*
注册需要被客户端访问的程序
类型对应值:bool->"xsd:boolean" string->"xsd:string"
int->"xsd:int" float->"xsd:float"
*/
$server->register( 'sayHello', //方法名
array("name"=>"xsd:string"), //参数,默认为"xsd:string"
array("return"=>"xsd:string") );//返回值,默认为"xsd:string"
//isset 检测变量是否设置
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
//service 处理客户端输入的数据
$server->service($HTTP_RAW_POST_DATA);
/**
* 供调用的方法
* @param $name
*/
/*
function sayHello($name) {
return "Hello, {$name}!";
}*/
function sayHello($name) {
$sql = "select issue_no from issue where reported_by='".$name."'";
$result=mysql_query($sql);
while($rows=mysql_fetch_object($result)){
$return.=$rows->issue_no;
}
return "{$return}";
}
?>
<?php
include 'include/include.php';
$lv_username=$_SESSION['username'];//用户名
require_once("lib/nusoap.php");
/*
通过WSDL调用WebService
参数1 WSDL文件的地址(问号后的wsdl不能为大写)
参数2 指定是否使用WSDL
$client = new soapclient('http://localhost/WebService/nusoapService.php?wsdl',true);
*/
$client = new soapclient('http://192.168.0.144:808/nusoapService.php');
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'UTF-8';
//参数转为数组形式传递
$paras=array('name'=>$lv_username);
//目标方法没有参数时,可省略后面的参数
$result=$client->call('sayHello',$paras);
//检查错误,获取返回值
if (!$err=$client->getError()) { echo "返回结果:",$result; }
else { echo "调用出错:",$err; }
?>
Company Info | \n"; $html .= "||||||
\n
| \n