PHP如何访问SOAP? PHP如何访问SOAP的webservice?需要SOAP函数?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 server2.php服务端<?php /** * 实现业务逻辑的类,此类是一个普通类 * */ class test { /** * 返回一个字符串:Hello World! * * @return string */ public function returnString(){ return "Hello World!"; } public function returnArray($array) { return array( array('id'=>0,'name'=>'a'), array('id'=>1,'name'=>'b'), array('id'=>2,'name'=>'c'), $array ); } public function sum($a,$b) { return $a+$b; }} /** * 创建Server对象 */ $arrOptions = array('uri'=>'http://example.com/'); //设置命名空间 $objSoapServer = new SoapServer(null,$arrOptions); /** * 注册Basic类的所有方法 */ $objSoapServer->setClass("test"); /** * 处理请求 */ $objSoapServer->handle(); ?> client.php客户端<?php /** * Client端,首先创建Client对象 */ $arrOptions = array('uri'=>'http://example.com/', //设置命名空间 'location'=>'http://localhost/test_/xmlrpc/server/server2.php', //设置Server地址 'trace'=>true); $objSoapClient = new SoapClient(null,$arrOptions); /** * 远程调用 */ echo "<pre/>";//try{ // $strReturn = $objSoapClient->returnString(); //}catch(Exception $e){ //} //echo $strReturn; $strReturn2 = $objSoapClient->returnArray(array('id'=>4,"name"=>"d")); print_r($strReturn2);$strReturn3 = $objSoapClient->sum(3,4); print_r($strReturn3);?> php 替换标题和主体内容 悬而未决:PHP和MS outlook的base64结果竟然不一样? php接收客户端post数据问题 ACCESS数据库中的数据重复..如何合并这些重复的记录.. 这样将字符串数组中的字符串转换为小写? 哪位有smartemplate和adodb的教程?例子就可以了。谢谢 数组处理问题! 关于php入门书籍推荐,请大家发挥 刚学PHP 在做一个小项目遇到一个问题,求指导! php telnet 问题,很慢才能取得返回值。 求讲解for循环里再进行for循环是怎么执行的 请问怎么用php 来post xml
/**
* 实现业务逻辑的类,此类是一个普通类
*
*/
class test {
/**
* 返回一个字符串:Hello World!
*
* @return string
*/
public function returnString(){
return "Hello World!";
}
public function returnArray($array)
{
return array(
array('id'=>0,'name'=>'a'),
array('id'=>1,'name'=>'b'),
array('id'=>2,'name'=>'c'),
$array
);
}
public function sum($a,$b)
{
return $a+$b;
}
}
/**
* 创建Server对象
*/
$arrOptions = array('uri'=>'http://example.com/'); //设置命名空间
$objSoapServer = new SoapServer(null,$arrOptions);
/**
* 注册Basic类的所有方法
*/
$objSoapServer->setClass("test");
/**
* 处理请求
*/
$objSoapServer->handle();
?> client.php客户端<?php
/**
* Client端,首先创建Client对象
*/
$arrOptions = array('uri'=>'http://example.com/', //设置命名空间
'location'=>'http://localhost/test_/xmlrpc/server/server2.php', //设置Server地址
'trace'=>true);
$objSoapClient = new SoapClient(null,$arrOptions);
/**
* 远程调用
*/
echo "<pre/>";
//try{
// $strReturn = $objSoapClient->returnString();
//}catch(Exception $e){
//}
//echo $strReturn;
$strReturn2 = $objSoapClient->returnArray(array('id'=>4,"name"=>"d"));
print_r($strReturn2);
$strReturn3 = $objSoapClient->sum(3,4);
print_r($strReturn3);
?>