PHP WebService calling. net using SOAP _ PHP Tutorial

Source: Internet
Author: User
PHP uses SOAP to call. net WebService. The project needs to exchange data with a. net system. the partner provides a WebService interface. This is a bit different from the general idea of using PHPPOST or GET to pass values and then check the database for data. you need to exchange data with a. net system, and the partner provides a WebService interface. This is a little different from the general idea of passing values through php post or GET and checking the database for data. The SOAP module is required, and the processing method is very simple. there are some things to be aware.

First, check that your PHP. ini has enabled. SOAP, that is, the semicolon before extension = php_soap.dll.

The code is simple:

 Soap_defencoding = 'utf-8'; $ client-> decode_utf8 = false; $ client-> xml_encoding = 'utf-8 '; $ param = array ('param1' => '01', 'param2' => '02'); // $ param ["param1"] = "01 "; // $ param ["param2"] = "02"; // $ result = $ client->__ soapCall ("GetArticle", array ($ param )); $ result = $ client->__ Call ("GetArticle", array ($ param); if (is_soap_fault ($ result) {trigger_error ("SOAP Fault: (faultcode: {$ result-> faultcode}, fault String: {$ result-> faultstring}) ", E_USER_ERROR);} else {$ data = $ result-> GetArticleResult; // class is returned here, you must use-> to obtain the value of the element print_r ($ data) ;}?>

It should be noted that the parameter is an array containing an array outside the array, that is, array ())

Some parameters of the SOAP interface are attached:

The following are examples of SOAP 1.2 requests and responses. The displayed placeholder must be replaced with the actual value.

POST /SearchService.asmx HTTP/1.1Host: 202.105.183.61Content-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://tempuri.org/GetTrafficViolationInfo"
 
   
      
         
    
     string
          
    
     string
        
     
  
 
HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Content-Length: length
 
   
      
         
    
     string
        
     
  
 

Bytes. This is a little different from the general idea of passing values through php post or GET and checking the database for data...

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.