yii-diandi/yii2-soap-server

SOAP Server Extension for Yii 2

dev-master 2020-07-22 02:08 UTC

This package is auto-updated.

Last update: 2024-03-22 10:07:25 UTC


README

Note, PHP SOAP extension is required.

Latest Stable Version Total Downloads Build Status

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist yii-diandi/yii2-soap-server "*"

or add

"yii-diandi/yii2-soap-server": "*"

to the require section of your composer.json file.

Usage

You need to add [[diandi\soapserver\Action]] to web controller.

Note, In a service class, a remote invokable method must be a public method with a doc comment block containing the '@soap' tag.

class ApiController extends Controller
{
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'hello' => 'diandi\soapserver\Action',
        ];
    }

    /**
     * @param string $name
     * @return string
     * @soap
     */
    public function getHello($name)
    {
        return 'Hello ' . $name;
    }
}

In case you want to disable the WSDL mode of SoapServer, you can specify this in the serviceOptions parameter as indicated below. You can use this when the request is to complex for the WSDL generator.

    /**
     * @inheritdoc
     */
    public function actions() {
        return [
            'index' => [
                'class' => 'diandi\soapserver\Action',
                'serviceOptions' => [
                    'disableWsdlMode' => true
                ]
            ]
        ];
    }