PHP5 SOAP Call Implementation process

Source: Internet
Author: User
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

Soap (Simple Object access Protocol) is a simple protocol for exchanging information in a decentralized or distributed environment, an XML-based protocol that consists of four parts: the SOAP Package (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 the PHP5

In the PHP configuration file php.ini, locate the
Extension=php_soap.dll
then remove the previous; Number and restart the Web service

Iii. querying Web service methods and parameters, data types

One 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
 
  __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. Submission of orders

This step involves stitching the XML string according to the development document, and then passing in as a parameter to the Introduceacceptedbusinessbystandardinterface
Create a acceptedbusiness.php with the following content
 
      
 
        
  
   
    
   * *
  Telecom
         
  Zhang San 13412341234 
         
  
   
  
         
  
   
  
         
  
   
    
   Guangdong Shenzhen
  
         
  
   
    
   iPhone 6
  
         
  
         
  
   
    
   1111111111111111111111111111111
  
         2111  
  
   
    
   1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111111111111111111111111111111
  
       
 
    ";    $return = $client->introduceacceptedbusinessbystandardinterface ($xml);    Print_r ($return);} catch (SoapFault $e) {    print_r (' Exception: '. $e);}? >
After executing in the browser, return
 
  
 
  
  
   
    
   0
  
   
  
   
    
   into single success!
  
   
  
   
    
   2014100905523549742
  
   
 
  
  • Related Article

    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.