Home >php教程 >php手册 >php soap 实例 不使用wsdl

php soap 实例 不使用wsdl

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:56:45865browse

http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan Server端+Client端 上篇用了wsdl这个写不用wsdl的. 声明:很简单!!!!!! 参考了如下: http://blog.csdn.net/phphot/archive/2007/07/15/1692109.aspx 类文件 ?php /** * 实现业务逻辑的类,此类是一

http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan

Server端+Client端

上篇用了wsdl这个写不用wsdl的.

声明:很简单!!!!!!

参考了如下:

http://blog.csdn.net/phphot/archive/2007/07/15/1692109.aspx

类文件

/**

* 实现业务逻辑的类,此类是一个普通类

*

*/

class Basic {

       /**

        * 返回一个字符串:Hello World!

        *

        * @return string

        */

       public function returnString($test){

               return "Hello World!".$test;

       }

}

?>

Server

 

/**

* Web Service的Server端,包含类文件。

*/

require_once("basic.php");

/**

* 创建Server对象

*/

$arrOptions = array('uri'=>'checkAPI');    //设置命名空间

$objSoapServer = new SoapServer(null,$arrOptions);

/**

* 注册Basic类的所有方法

*/

$objSoapServer->setClass("Basic");

/**

* 处理请求

*/

$objSoapServer->handle();

?>

 

Client

 

/**

* Client端,首先创建Client对象

*/

$arrOptions = array('uri'=>'checkAPI',                     //设置命名空间

                       'location'=>'http://localhost/user/soaptest.php',        //设置Server地址

                       'trace'=>true);

$objSoapClient = new SoapClient(null,$arrOptions);

/**

* 远程调用

*/

$test='ok123';

try{

   $strReturn = $objSoapClient->returnString($test);

}catch(Exception $e){

}

/**

* 打印结果

*/

echo $strReturn;

?>

 

 

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn