WebService-php-1 (16)

Source: Internet
Author: User
: This article mainly introduces the WebService-php-1 (16), for PHP tutorials interested in students can refer to it. Recently I have read a lot of documents about webservice in php. thanks to the sharing of Yan 18, it helped me build the server. The learning notes are recorded as follows, including the notes of Yan 18.

WebService

1. quick introduction to WebService

In general, the remote server method is called in a certain XML format, and the server returns XML content in a certain format.
"A certain format" ---- SOAP (Simple Object Access Protocol) Simple Object Access Protocol is a Simple Protocol for exchanging information in a distributed or distributed environment. it is an XML-based Protocol.
Discussion.
Remote server-messages are generally transmitted over HTTP.
Conclusion: WebServie = XML in HTTP + Soap format

Example 1: soap request

POST/WebServices/MobileCodeWS. asmx HTTP/1.1
Host: webservice.webxml.com.cn
Content-Type: text/xml; charset = utf-8
Content-Length: 354
SOAPAction: "http://WebXml.com.cn/getMobileCodeInfo"
  
   And restart apache
PHP SoapClient class can be used to request WebService

$soap = new soapClient('http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL');print_r($soap->getMobileCodeInfo( array('mobileCode'=>'13**********') ) );

Array([0] => getMobileCodeInfoResponse getMobileCodeInfo(getMobileCodeInfo $parameters)[1] => getDatabaseInfoResponse getDatabaseInfo(getDatabaseInfo $parameters))Array([0] => struct getMobileCodeInfo {string mobileCode;string userID;}[1] => struct getMobileCodeInfoResponse {string getMobileCodeInfoResult;}[2] => struct getDatabaseInfo {}[3] => struct getDatabaseInfoResponse {ArrayOfString getDatabaseInfoResult;}[4] => struct ArrayOfString {

String;
}

// Call method print_r ($ soap-> getMobileCodeInfo (array ('lelecode' => '20140901 ')));

Returned results

StdClass Object ([getMobileCodeInfoResult] => 13 **********: Beijing Mobile phone motion zone card)

3. construct a WebService server

What is wsdl?
Wsdl is the specification of WebService.

 
 
  
  
   
  
  
  
   
  
  
   
  
  
  
   
    
    
   
  
  
  
   
   
   
   
    
    
    
    
     
   
  
  
  
   
    
   
  
 

The above introduces WebService-php-1 (16), including some content, and hope to be helpful to friends who are interested in PHP tutorials.

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.