We have used php soap extension to establish the server and client programs, and used third-party class libraries to create the wsdl
We have used php's soap extension to establish the server and client programs, and used a third-party class library to create the wsdl.
Server. php (server) Write_log ($ select_ SQL, $ this-> log_file); return $ select_ SQL;}/** function: write logs * $ file_name: log file name * $ string: log content */private function write_log ($ string, $ file_name) {date_default_timezone_set ("Asia/Shanghai"); $ now_time = date ("Y-m-d H: m: s "); $ file_resource = fopen ($ file_name, 'A'); fwrite ($ file_resource, $ now_time. '= '. $ string. "\ r \ n"); fclose ($ file_resource) ;}// generate the soap server $ server = new SoapServer ('service. wsdl ', array ('soa P_version' => SOAP_1_2); $ server-> setClass ("Service"); // register all methods of the Service class $ server-> handle (); // process the request?> ========================================================== ========================================================== ======== Client. php (client) _ SoapCall ('start _ dk ', array (1, 2); echo $ soap_return;?> ========================================================== ========================================================== ======== Service. wsdl) ========================================================== ========================================================== ======== The above three files form a complete web service. Let's talk about an interesting topic today. Can we use a more underlying method to implement php soap communication. The answer is yes. If you know something about soap, you must understand that soap is essentially a text in xml format. http post requests are used as channels to exchange data between the server and the client, so that the request Service can exchange data. Next we will take you to improve client. php and request the server in a more underlying way, which will help you have a deeper understanding of soap. ========================================================== ========================================================== ======== Client. php (client) 1 2 '; // Use curl to send the soap client request to the server $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, "http: // localhost/soap_demo/server. php "); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ ch, CURLOPT_POST, 1); curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ soap ); $ data = curl_exec ($ ch); curl_close ($ ch); // The Output Server returns var_dump ($ data);?> ========================================================== ========================================================== ====== Running result UPDATE 'dk _ day_data 'SET 'data _ clear' = 0 WHERE 'DB _ name' = '1' AND 'time' = '2' ========================================================== ========================================================== Yes. The soap request sent using php extension is returned by the soap server method when the soap response is received. The soap request sent using the soap body + post method is the original soap response when the soap response is received. The return value of the method is included in Medium