PHP之Web Service - NuSOAP 体验
时间:2008-03-17 来源:btpka3
想用PHP创建一个Web Service,并让Flex能够调用,所以就下载了含有PDT的Eclipse3.3,下载了Xampp,下载了NuSOAP,以下是初步使用了NuSOAP创建一个简单的Web 服务:
呵呵,初战告捷,当然了该服务是经过Flex测试的,可以被正确调用的!
路径分别为:
http://localhost/TestNusoap/server.php
http://localhost/TestNusoap/client.php
server.php
configureWSDL("myTestNuSOAPServer");
//注册服务
$mySrvc->register(
"myPlus",
array("num1"=>"xsd:decimal", "num2"=>"xsd:decimal"),
array("return"=>"xsd:decimal"),
//"return"=>"xsd:number"
//faultCode:DecodingError
//faultString:'Cannot unmarshall type 'http://www.w3.org/2001/XMLSchema::number' from XML.'
"http://btpka3"
//
//
//
//faultCode:EncodingError
//faultString:'Error #1098: no namespace 带有非法前缀 ns0
);
//faultCode:DecodingError faultString:'SOAP Response Version Mismatch' faultDetail:'null'
//开启服务
$mySrvc->service($HTTP_RAW_POST_DATA);
?>
client.php
$n1,"num2"=>$n2);
//调用服务中的函数
$sum = $client->call("myPlus", $params);
$err = $client->getError();
//打印结果
echo $err."
";
echo "$n1 + $n2 = ";
echo $sum;
?>
server.php 生成的 WSDL 描述文档
路径为:
http://localhost/TestNusoap/server.php?wsdl
[url=http://localhost/TestNusoap/server.php][/url]
内容如下:
呵呵,初战告捷,当然了该服务是经过Flex测试的,可以被正确调用的!
路径分别为:
http://localhost/TestNusoap/server.php
http://localhost/TestNusoap/client.php
server.php
configureWSDL("myTestNuSOAPServer");
//注册服务
$mySrvc->register(
"myPlus",
array("num1"=>"xsd:decimal", "num2"=>"xsd:decimal"),
array("return"=>"xsd:decimal"),
//"return"=>"xsd:number"
//faultCode:DecodingError
//faultString:'Cannot unmarshall type 'http://www.w3.org/2001/XMLSchema::number' from XML.'
"http://btpka3"
//
//
//
//faultCode:EncodingError
//faultString:'Error #1098: no namespace 带有非法前缀 ns0
);
//faultCode:DecodingError faultString:'SOAP Response Version Mismatch' faultDetail:'null'
//开启服务
$mySrvc->service($HTTP_RAW_POST_DATA);
?>
client.php
$n1,"num2"=>$n2);
//调用服务中的函数
$sum = $client->call("myPlus", $params);
$err = $client->getError();
//打印结果
echo $err."
";
echo "$n1 + $n2 = ";
echo $sum;
?>
server.php 生成的 WSDL 描述文档
路径为:
http://localhost/TestNusoap/server.php?wsdl
[url=http://localhost/TestNusoap/server.php][/url]
内容如下:
相关阅读 更多 +
排行榜 更多 +