It’s very simple, no need for extra explanation, it returns a string.
2. soapServer.php - Server class, providing services
1
2 //Server
3 require_once('Myself.class.php');
4 $parameter=array(
5 'uri'=>'http://localhost/',
6 'location'=>'http://localhost/soap/soapServer.php'
7 );
8 $soapServer=new SoapServer(null,$parameter);
9 $soapServer->setClass('Myself');
10 $soapServer->handle();
11 ?>
Copy code
SoapServer has two operating modes:
The above example is non-WSDL mode. When instantiating the SoapServer class, one parameter is to put the WSDL file. In non-WSDL mode, it can be empty, and the configuration parameters are written in the form of an array in the second parameter. .
If you are using WSDL mode, you can directly use the WSDL file to let the server read the configuration parameters. In this case, you can omit the second array parameter.
There are many configuration parameters. Only 2 are listed above for simple examples. You can check the details online
uri --namespace
location --service address
1. WSDL mode In WSDL mode, the constructor can use the WSDL file name as a parameter and extract the information used by the service from the WSDL.
2. Non-WSDL mode In the non-WSDL mode, parameters are used to pass the information to be used to manage the behavior of the service.
Among the many methods of the SoapServer class, three methods are more important. They are SoapServer::setClass(), SoapServer::addFunction(), SoapServer::handle().
Special attention should be paid to the fact that no parameters can be output before or after the handle method, otherwise an error will occur.
3. soapClient.php --Client class, using service
Copy code
1
2 //Client
3 $parameter=array(
4 'uri'=>'http://localhost/',
5 'location'=>'http://localhost/soap/soapServer.php'
6 );
7 try{
8 $soapClient=new SoapClient(null,$parameter);
9 echo $soapClient->info();
10
11 }catch(Exception $e){
12 echo $e->getMessage();
13 }
14
15 ?>
Copy code
The SoapClient class can serve as a client for given WebServices.
http://www.bkjia.com/PHPjc/859801.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/859801.htmlTechArticleUsing PHP SOAP extension to implement simple Web Services What can WebServices do? WebServices can convert applications into web applications. By using WebServices, your application can...
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