Php provides an extension Library dedicated for soap operations. With this extension library, you can directly perform soap operations in php. The following describes the basic operations of soap. Php provides an extension library for soap operations.
You can directly perform soap operations in php. The following describes the basic operations of soap.
I. use of soap extension
The php soap extension library implements the client and server through the soap protocol.
Data interaction. Since php5.0, php comes with soap support. Use
The soap Extension Library must first modify the configuration file php. ini in the php installation directory.
To activate the soap Extension Library.
Find the following line of code in the php. ini file and remove the comment (;).
; Extension = php_soap.dll
After modification, restart the web server to activate the soap extension. In the soap Extension Library
Contains three objects.
1. SoapServer
SoapServer is used to define the functions that can be called and returned when creating a php server page.
Response data. The syntax format for creating a SoapServer object is as follows:
$ Soap = new SoapServer ($ wsdl, $ array );
$ Wsdl is the wsdl file used by shoap. wsdl is a type of Web Service description.
Standard format. if $ wsdl is set to null, the wsdl mode is not used. $ Array is
The attribute information of SoapServer, which is an array.
The addFunction method of the SoapServer object is used to declare which function can be called by the client,
Syntax format: (php blog | php technical blog www.phpcq.com)
$ Soap-> addFunction ($ function_name );
$ Soap is a SoapServer object, and $ function_name is the name of the function to be called.
The handle method of the SoapServer object is used to process user input, call the corresponding function, and finally return
The result to be processed by the client. Syntax format: (php blog | php technical blog www.phpcq.com)
$ Soap-> handle ([$ soap_request]);
$ Soap is a SoapServer object, and $ soap_request is an optional parameter to indicate
User request information. If $ soap_request is not specified, the server will receive all
Request.
2. SoapCliet
SoapClient is used to call the SoapServer page on the remote server and call the corresponding function.
. The syntax format for creating a SoapClient object is as follows:
$ Soap = new SoapClient ($ wsdl, $ array );
The $ wsdl and $ array parameters are the same as those of SoapServer.
After creating a SoapClient object, calling the functions on the server page is equivalent to calling the SoapClient method,
Syntax: (php blog | php technical blog www.phpcq.com)
$ Soap-> user_function ($ params );
$ Soap is a SoapClient object, and user_function is the function to be called by the server, $ params
Is the parameter to pass in the function.
3. SoapFault
SoapFault is used to generate possible errors during soap access. Syntax format of creating a soapFault object
(Php blog | php technical blog www.phpcq.com)
$ Fault = new SoapFault ($ faultcode, $ faultstring );
$ Faultcode is the user-defined error code, and $ faultstring is the user-defined error message. SoapFault
The object is automatically generated when an error occurs on the server page or when you create a SoapFault object by yourself. For
Errors during Soap access. the client can capture the SoapFalut object to obtain the corresponding error information.
After capturing the SoapFault object on the client, you can use the following code to obtain the error code and error information.
$ Fault-> faultcode; // error code
$ Fault-> faultstring; // error message
$ Fault is the SoapFault object created earlier.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service