SOAP call implementation process in PHP5

Source: Internet
Author: User
SOAP call implementation process in PHP5 This article introduces the implementation process of SOAP call in PHP5 by taking a company's iPhone 6 mobile phone reservation interface development as an example.

I. basic concepts Simple Object Access Protocol (SOAP) Simple Object Access Protocol is a Simple Protocol for exchanging information in a distributed or distributed environment. it is an XML-based Protocol, it consists of four parts: SOAP encapsulation (envelop), which defines a framework that describes the content of a message, who sent the message, who should accept and process it, and how to process it; the SOAP encoding rules (encoding rules) are used to represent the data type instances required by the application; the soap rpc representation (RPC representation) indicates the protocols for remote process calls and responses; SOAP binding, which uses the underlying protocol to exchange information.

Web Service Description Language (WSDL) is the standard XML format used to describe XML Web services. WSDL is proposed by developers such as Arba, Intel, IBM, and Microsoft. It defines the operations and messages sent and received by a given Web service in an abstract way unrelated to a specific language. In terms of its definition, you cannot regard WSDL as an object interface definition language. for example, the application architecture such as CORBA or COM will use the object interface definition language. WSDL maintains protocol neutral, but it does have built-in support for binding SOAP, thus establishing an inseparable relationship with SOAP. So when I talk about WSDL in this article, I assume that you use SOAP as your communication protocol.

Although SOAP and WSDL are two standards of web services, they are not necessarily related 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.

2. configure PHP5 in the php configuration file php. ini and find
extension=php_soap.dll
Remove the previous; number, and then restart the web service.

3. query web service methods and parameters. The data type of a provincial telecommunications company's incoming ticket interface is http: // *** .ct2.16.com/services/acceptedbusiness? Wsdl
We use the _ geunctions () and _ getTypes () methods of SoapClient to view the methods, parameters, and data types of this interface.
Only interfaces listed in _ getFunctions can be called by soap.
Create code soap. php in the root directory
 __getFunctions());print_r($client->__getTypes());  } catch (SOAPFault $e) {print $e;}?>
After you run http: // localhost/soap. php in a browser, the following result is returned:
Array
(
[0] => ArrayOf_xsd_anyType introduceAcceptedBusiness (string $ c3, string $ c4, string $ linkman, string $ linknum, string $ num, string $ idcard, string $ remark, string $ address)
[1] => ArrayOf_xsd_anyType encode (string $ subname, string $ linkphone, string $ idcard, string $ address, string $ businesstype, string $ marketcode, string $ surveycode, string $ commanager, string $ commanagerphone, string $ bendiwang, string $ fenju, string $ zhiju, string $ remark)
[2] => string introduceAcceptedBusinessByStandardInterface (string $ xmlStr)
[3] => string introduceAcceptedBusinessByCallOut (string $ xmlStr)
[4] => string introduceacceptedbusin1_yyddj (string $ xmlParam)
[5] => ArrayOf_xsd_anyType queryacceptedbusin1_yaizhuangwei (string $ surveycode, string $ starttime, string $ endtime)
[6] => string queryCallOutOrderByConfig (string $ xmlParam)
)
Array
(
[0] => anyType ArrayOf_xsd_anyType []
)
There is a method introduceAcceptedBusinessByStandardInterface (string $ xmlStr), which will be the interface to be used in the development documentation. the parameter is an xml string.
In addition, some interfaces mentioned SoapHeader authentication, which requires the _ setSoapHeaders method, the specific can view the http://php.net/manual/zh/soapclient.setsoapheaders.php

4. This step is to concatenate an xml string based on the development document and pass it in as an introduceAcceptedBusinessByStandardInterface parameter.
Create acceptedbusiness. php with the following content:
     
       
  
   
** China Telecom
        
        
  
   
Zhang San
        
  
   
13412341234
        
  
   
Guangdong, Shenzhen
        
  
   
IPhone 6
        
        
  
   
1111111111111111111111111111111
  2111  
  
   
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
      
 "; $ Return = $ client-> introduceAcceptedBusinessByStandardInterface ($ xml); print_r ($ return);} catch (SOAPFault $ e) {print_r ('exception :'. $ e) ;}?>
After Execution in the browser, return
 
 
  
   
0
  
  
   
Ticket entered!
  
  
   
2014100905523549742
  
 

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.