E
E
EVOSandru62018-02-06 13:29:58
This
EVOSandru6, 2018-02-06 13:29:58

How to properly truncate the soapAction parameter in the nusoap library on YII1 to a specific action or class method?

Good afternoon,
Such a trouble, it is necessary to correctly cut the handler method - controller action or class method (static or regular) when forming the WSDL . The project structure has a soap module It has a ManagersController controller


class ManagersController extends CController
{
    public function setData($name, $age, $sex)
    {
       // логика
    }
}

There is also a SoapService component , where I originally wanted to implement logic instead of ManagersController::setData() ( it would be better, but as I understand it, this option will not work)
Server:
header('Content-Type: text/xml; charset=utf-8');

        $this->soap_server->configureWSDL('setWebBox','webServer');
        $this->soap_server->decode_utf8 = false;
        $this->soap_server->soap_defencoding = 'UTF-8';

        $this->soap_server->wsdl->addComplexType(
            'ArrayOfString',
            'complexType',
            'array',
            '',
            'SOAP-ENC:Array',
            [],
            [
                ['ref'=>'SOAP-ENC:Array',
                    'wsdl:arrayType' => 'SOAP-ENC:string[]',
                    'arrayType' => 'SOAP-ENC:string[]',
                    'nillable'=>'true'
                ]
            ],
            'SOAP-ENC:string'
        );

       ...

        $this->soap_server->register(
            'setManager',
            [
                'name'=>'xsd:string',
                'age' => 'xsd:int',
                'sex' => 'xsd:string',
            ],
            [
                'code' => 'xsd:int',
                'message' => 'xsd:string'
            ],
            '',
            'uri:soap/managers/getData',
            'document',
            'literal'
        );

       ...

        // Подключаем обработчика запросов
        $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
        $this->soap_server->service($HTTP_RAW_POST_DATA);

1. If I use the following instead of this register option :
$this->soap_server->register(
            'setManager',
            [
                'ID_1C' => 'xsd:int',
                'FIRST_NAME'=>'xsd:string',
                'LAST_NAME' => 'xsd:string',
                'THIRD_NAME' => 'xsd:string',
                'EMAIL' => 'xsd:string',
                'PARENT_BRANCH_ID' => 'xsd:int',
                'LESS_ONE_YEAR' => 'xsd:int'
            ],
            [
                'code' => 'xsd:int',
                'message' => 'xsd:string'
            ],
            '',
            '',
            'document',
            'literal'
        );

Then if this server is not in the context of the framework, then the function by the name of the method successfully executes - setManager
response:
Array ( [code] => 0 [message] => UPDATE OK )
2. If I understand correctly, then to call methods in the context framework, you need to change either the name of the first parameter in register or the 5th parameter of soapAction('uri:...')
It turns out that if I change soapAction, then nothing changes at all, and the function (a crutch temporary option) is processed just as successfully.
If I change the first parameter in the registry to ' soap/managers/ManagersController.setManager ',
then firstly everything breaks:
Array ( [faultcode] => SOAP-ENV:Client [faultactor] => [faultstring] => Operation 'setManager' is not defined in the WSDL for this service [detail] => )

Client:
public function nusoapClient()
    {
        header('Content-Type: text/html; charset=utf-8');
        // Создаем экземпляр клиента
        $client = new nusoap_client('http://tbox.a-i.kz/public/wbs/service.php/?wsdl');
        $client->setCredentials('Web_user','[email protected]','basic');
        $params = [
            'id' => 199,
            'name' => 'RRRR',
            'sex' => 'aswe',
            'age' => 7,
        ];
        // Вызываем SOAP-метод
        $result = $client->call('setManager', $params);
        // Отображаем результат
        print_r($result);
        // Отображаем запрос и ответ
        echo '<h2>Запрос</h2>';
        echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
        echo '<h2>Ответ</h2>';
        echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
        die();
    }

Tell me - how to be?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question