In this paper, an example of the development of a company's iphone 6 mobile phone reservation interface is introduced, and the implementation process of soap call is PHP5.
First, the basic concept of soap (Simple Object access Protocol) is a simple protocol to exchange information in a decentralized or distributed environment, is an XML-based protocol, it consists of four parts: Soap Encapsulation (envelop), The wrapper defines a framework that describes what the content in the message is, who sent it, who should accept and handle it, and how to handle it; the SOAP encoding rule (encoding rules), which represents an instance of the data type that the application needs to use; SOAP RPC Representation (RPC representation), which represents the contract for remote procedure calls and replies; A SOAP binding (binding) that uses the underlying protocol to exchange information.
WSDL (Web service Description Language) is the standard XML format for describing XML Web services, and WSDL is presented by developers such as Ariba, Intel, IBM, and Microsoft. It defines the operations and messages sent and received by a given Web service in an abstract way that is not specific to the language. In its definition, you cannot consider WSDL as an Object interface definition language, for example, application architectures such as CORBA or COM use the Object interface definition language. WSDL maintains protocol neutrality, but it does have built-in support for binding soap, thus establishing an inextricable connection with soap. So, when I discuss WSDL in this article, I'll assume that you have soap as your communication protocol.
While soap and WSDL are two of the standards of Web service, they are not necessarily connected and can be used independently. The relationship between them is similar to the relationship between HTTP and HTML. The former is a protocol, and the latter is a description of a Web server.
Second, the configuration under PHP5 in the PHP configuration file php.ini, found
Extension=php_soap.dll
then remove the previous; Number and restart the Web service
Third, query Web service methods and parameters, data type a province telecom company's entry interface is HTTP://***.CT10000.COM/SERVICES/ACCEPTEDBUSINESS?WSDL
We use SoapClient's __geunctions () and __gettypes () methods to view the interface's methods, parameters, and data types
Only the interfaces listed in __getfunctions can be called by soap.
Create code under the root directory soap.php
<?phpheader ("Content-type:text/html;charset=utf-8"); try {$client = new SoapClient ("http://***.ct10000.com/ SERVICES/ACCEPTEDBUSINESS?WSDL ");p Rint_r ($client->__getfunctions ());p Rint_r ($client->__gettypes ()); } catch (SoapFault $e) {print $e;}? >
After the browser runs: http://localhost/soap.php, the results are as follows
Array
(
[0] = Arrayof_xsd_anytype introduceacceptedbusiness (string $c 3, String $c 4, String $linkman, String $linknum, String $ num, String $idcard, String $remark, String $address)
[1] = = Arrayof_xsd_anytype Introduceacceptedbusinessbyaizhuangwei (string $subname, String $linkphone, String $ Idcard, String $address, String $businesstype, String $marketcode, String $surveycode, String $commanager, String $commana Gerphone, String $bendiwang, String $fenju, String $zhiju, String $remark)
[2] = = String Introduceacceptedbusinessbystandardinterface (string $xmlStr)
[3] = = String Introduceacceptedbusinessbycallout (string $xmlStr)
[4] = = String Introduceacceptedbusinessbyyddj (string $xmlParam)
[5] = = Arrayof_xsd_anytype Queryacceptedbusinessbyaizhuangwei (string $surveycode, String $starttime, String $ Endtime
[6] = = String Querycalloutorderbyconfig (string $xmlParam)
)
Array
(
[0] = AnyType arrayof_xsd_anytype[]
)
There is a method Introduceacceptedbusinessbystandardinterface (string $xmlStr) that will be the interface to be used in the development documentation, with the arguments as XML strings
There are other interfaces mentioned in the SoapHeader certification, which requires the addition of __setsoapheaders method, specific to see http://php.net/manual/zh/soapclient.setsoapheaders.php
Iv. submitting a single step is the need to stitch the XML string according to the development document, and then pass it as the Introduceacceptedbusinessbystandardinterface parameter
Create a acceptedbusiness.php with the following content
<?phpheader ("Content-type:text/html;charset=utf-8"); try {$client = new SoapClient (' http://***.ct10000.com/ Services/acceptedbusiness?wsdl '); $xml = "<?xml version= ' 1.0 ' encoding= ' UTF-8 '?> <PACKAGE> <c3& gt;** Telecom </C3> <C4></C4> <LINKMAN> Zhang San </LINKMAN> <linknum>13412341234</l inknum> <LINKADDRESS> Guangdong Shenzhen </LINKADDRESS> <remark>iphone 6</remark> <channel> ;</channel> <GRIDCODE>1111111111111111111111111111111</GRIDCODE> <agentcode>2111</age Ntcode> <KEY> 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111</key> </PACKAGE> "; $return = $client->introduceacceptedbusinessbystandardinterface ($xml); Print_r ($return);} catch (SoapFault $e) {print_r (' Exception: '. $e);}? >
After executing in the browser, return
<?xml version= "1.0" encoding= "UTF-8"?><package><status>0</status><reason> into single success!< /reason><orderseq>2014100905523549742</orderseq></package>
PHP5 SOAP Call Implementation process