Publish and call PHPWebservice

Source: Internet
Author: User
Publish and call PHPWebservice 1. configure the php environment. ini: remove the semicolon in front of php_soap.dll. Otherwise, the error classsoapservernotfound will be reported, restart apache, and view it through phpinfo (). This indicates that the environment already supports soap webservice, And the next thing is to write code. 2. Publishing webservice

Publishing and calling of PHP Webservice 1. configure the php environment. ini: remove the semicolon in front of php_soap.dll. Otherwise, the class soapserver not found will be reported. Restart apache and run phpinfo () to check whether the environment supports soap webservice, the next thing is to write code. 2. Publishing webservice

Publish and call PHP Webservice

1. Environment Configuration

Configure php. ini and remove the semicolon before php_soap.dll,

Otherwise, an error is reported.

Class soapserver not found

After apache is restarted, use phpinfo () to view

This means that the environment already supports soap webservice, And the next thing is to write code.

2. Publishing webservice

The *. wsdl file released is actually an xml file, which can be generated through the 3rd-party software, such as ZendStudio.

For example, use the following code:

 oParams[l1] ;              $oParams = json_decode($sParams);              $a = $oParams->a;              $b = $oParams->b;              $c = $a+$b;              return array('AddResult'=>$c);       }}?>


The generated xml file is:

   
  
   
    
     
      
       
        
        
       
     
     
      
       
        
        
       
      
     
   
    
      
   
    
      
   
   
     
       
       
     
   
    
     
     
      
      
        
     
      
        
      
     
   
    
     
     
      
      
        
     
      
        
      
     
   
   
     
       
    
     
       
     
    
 


After an xml file is generated, it must be published through a service, for example:

 setClass('CTest');$server->handle();?>


You can then provide the departure address to others or the system, for example:

Http: // 192.168.6.44/webservice/server. php? Wsdl

3. webservice call

Write a call page using the address provided above

 Add (array ('oparams '=> $ str); // array // call method 2 // $ pParams-> oParams = $ str; // $ r = $ client->__ call ('add', array ($ pParams); // The object must be var_dump ($ r);?>

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.