Implement SOAP with WSDL in PHP

Source: Internet
Author: User
Implement SOAP with WSDL in PHP and install and generate the library required for WSDL with composer

composer require piotrooo/wsdl-creator

Implementation of the portal file for external access. for sample code, see (the method name and Notify in the parameter correspond to a class name, and the method of this class will become an external interface that can be called through SOAP ):

 renderWSDL();            exit;        }        $server = new SoapServer(null, [            'uri' => $soapuri        ]);        $server->setClass('Notify');        $server->handle();    }}

To implement a class file that contains the interface function logic, see the sample code (the method annotation is very important, which is the basis for the wsdl-creator to correctly generate the WSDL, and must be annotated strictly according to the format ):

Class Notify y {/*** @ desc sendText send text information to the patient * @ param string $ user to which user * @ param string $ content * @ return string $ result */public function sendText ($ toUser, $ content) {if (! $ ToUser |! $ Content) {return E: INVALID;} $ user = G: xpdo ()-> row ("SELECT * FROM 'users' WHERE 'atientid' =? ", [$ ToUser]); if (! $ User) {return E: NODATA;} $ api = G: xpdo ()-> row ("SELECT * FROM 'api 'WHERE 'token' =? ", [$ User ['token']); $ weixin = new Weixin ($ api ['appid '], $ api ['appsecret']); $ weixin-> sendText ($ user ['openid'], $ content); return 0 ;}}

Debug interfaces using SoapUI software

Prepare corresponding API call instructions

References:

For more information about the basic SOAP document structure, see http://www.sitepoint.com/series/creating-web-services-with-php-and-soap/] for more information about generating the WSDL Library wsdl-creator, see: https://github.com/piotrooo/wsdl-creator

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.