Ec (2); I learned several languages and sometimes thought back, but I found that there was no accumulation, but I liked to sell myself; how can I do not fall, So I forced myself to write a diary, however, I think it's boring to talk to myself. I just want to write the log as a tutorial, so I didn't give any reference to the hard nut-and-mortar students in the community. the younger brother has no experience. I hope those who see this article will forgive me more .... php5 comes with an extended extensionphp_soap.dll for webservice development; in p script ec (2); in script
I learned several languages and sometimes thought back, but found that there was no accumulation, but I liked to show off; how can I not fall, So I forced myself to write a diary, however, I think it's boring to talk to myself. I just want to write the log as a tutorial, so I didn't give any reference to the hard nut-and-mortar students in the community. the younger brother has no experience. I hope those who see this article will forgive me more ....
Php5 comes with an extended extension = php_soap.dll for developing web Services;
Add the above extension to php. ini, and configure the following options for the ini file:
Name Default Changeable Changelog
Soap. wsdl_cache_enabled "1" PHP_INI_ALL Available since PHP 5.0.0.
Soap. wsdl_cache_dir "/tmp" PHP_INI_ALL Available since PHP 5.0.0.
Soap. wsdl_cache_ttl "86400" PHP_INI_ALL Available since PHP 5.0.0.
In this way, you can use SoapServer.
Create a file with the following content:
Class service_class {
/**
* @ Return string
**/
Function sayHello (){
Return ''hello world '';
}
/**
* @ Param string $ name;
* @ Return string;
*/
Function getName ($ name ){
Return $ name;
}
}
$ Server = new SoapServer (''buildin. wsdl ''); (1)
$ Server-> setClass (''service _ class''); (2)
$ Server-> handle (); (3)
?>
Note: If the generated wsdl file has a type, you should use the method annotation; (string, integer, etc ).
(1) generate an instance with the parameter "buildin. wsdl is the location where the wsdl file is located, because the SoapServer has not yet provided the Implementation of generating the wsdl, because it must refer to the location where the detailed wsdl file is located.
(2) register the methods provided by webservice. By default, all methods in the class are registered.
(3) processing requests;
So far, access the PHP file in the browser. If the prompt appears
"Cant find HTTP_RAW_POST_DATA"; Insert the following code before creating the soapServer:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
If (! Isset ($ HTTP_RAW_POST_DATA )){
$ HTTP_RAW_POST_DATA = file_get_contents ('php: // input '');
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
If an error such as bad request is prompted, the web service has been started.
If you have not forgotten the wsdl mentioned above, you must consider the buildin. where does wsdl come from? If you are familiar with zend studio, you will think of the wsdl generator under the tool menu. By the way, you can use this tool to generate a very handsome wsdl file, I will not talk about the usage here, so I will know how to generate it twice ..
Server ends here.
The day is here first, and if you call the delphi client tomorrow .....
<