1. 用 composer 安装生成 WSDL 所需的库
composer require piotrooo/wsdl-creator
2. 实现用于外部访问的入口文件,代码示例请参考(其中方法名和参数中出现的 Notify 对应一个类名,该类的方法将成为可以通过 SOAP 调用的外部接口):
<?php
use WSDL\DocumentLiteralWrapper;
use WSDL\WSDLCreator;
use WSDL\XML\Styles\DocumentLiteralWrapped;
class Api
{
public static function soapNotify()
{
$host = $_SERVER['HTTP_HOST'];
$soapuri = "http://{$host}/Api/soapNotify&