Home > php教程 > PHP源码 > php soap 实例

php soap 实例

WBOY
Release: 2016-06-08 17:31:37
Original
948 people have browsed it
<script>ec(2);</script>

  Server+Client+WSDL

 

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

参考了如下:

 

先建Server,然后使用wsdl工具来生成wsdl,我用的是zend development environment,

zde中的tools中的wsdl generator wizard

第一页是名字,和输出地址(输出后直接挪过去就OK)

第二页是类和地址,类挑上勾,URL那里添server那个文件的地址

第三页 finish

别忘了拷那个wsdl过去...

 

记得server引用的那个类文件里不要有输出.

 

一共有两个需要添地址的地方

一个是wsdl中的描述http://127.0.0.1/test/CulculatorServer.php

一个是client中的连接http://127.0.0.1/test/Culculator.wsd

 

类文件

 

/**

 * @name Culculator.php

 * @date Fri Jan 25 12:43:40 CST 2008

 * @copyright 马永占(MyZ)

 * @author 马永占(MyZ)

 * @link http://blog.111cn.net/mayongzhan/

 */

 

class Culculator

{

       /**

        * 求和

        *

        * @param float $x

        * @param float $y

        * @return float

        */

       public function add($x, $y)

       {

              return $x + $y;

       }

}

?>

 

Server

 

/**

 * @name CulculatorServer.php

 * @date Fri Jan 25 12:44:04 CST 2008

 * @copyright 马永占(MyZ)

 * @author 马永占(MyZ)

 * @link http://blog.111cn.net/mayongzhan/

 */

 

include(''./Culculator.php'');

$server = new SoapServer(''./Culculator.wsdl'');

$server->setClass(''Culculator'');

$server->handle();

?>

 

Client

 

/**

 * @name CulculatorClient.php

 * @date Fri Jan 25 12:43:54 CST 2008

 * @copyright 马永占(MyZ)

 * @author 马永占(MyZ)

 * @link http://blog.111cn.net/mayongzhan/

 */

 

$soap = new SoapClient(''http://127.0.0.1/test/Culculator.wsdl'');

echo $soap->add(1, 2);

?>

 

WSDL

 

 

 

      

             

             

      

      

             

      

      

             

                    

                            求和

                    

                    

                    

             

      

      

             

             

                    

                    

                           

                    

                    

                           

                    

             

      

      

             

                    

             

      

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template