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