尝试连接到SOAP服务时出错

时间:2018-07-31 17:10:57

标签: php laravel soap

我正在尝试使用巴西CADSUS服务的“搜索”功能,但出现以下错误:

"Forced circuit exception";

在下面,我有以下代码,该代码使用Laravel 5.6和PHP 7.1

Route::get('/ws/teste', function () {
    try {
        $opts = array(
            'http' => array(
                'user_agent' => 'PHPSoapClient'
            )
        );
        $context = stream_context_create($opts);
        $wsdlUrl = 'https://servicoshm.saude.gov.br/cadsus/CadsusService/v5r0?wsdl';
        $soapClientOptions = array(
            'trace' => 1,
            'stream_context' => $context,
            'cache_wsdl' => WSDL_CACHE_NONE,
            'Username' => '*****',
            'Password' => '*****'
        );
        $client = new SoapClient($wsdlUrl, $soapClientOptions);
        $parameters = array(
            'CNESUsuario' => array(
                'CNES' => '6963447',
                'Usuario' => 'LEONARDO',
                'Senha' => ''
            ),
            'FiltroPesquisa' => array(
                'nomeCompleto' => 'SERGIO ARAUJO CORREIA LIMA',
                'tipoPesquisa' => 'IDENTICA'
            ),
            'higienizar' => 0
        );
        $result = $client->pesquisar($parameters);
        print_r($result);
    }
    catch(\Exception $e) {
        echo $e->getMessage();
    } });

我将不胜感激。预先感谢

1 个答案:

答案 0 :(得分:1)

来自SOAP响应:

[cvc-minLength-valid: Value '' with length = '0' is not facet-valid with
respect to minLength '1' for type '#AnonType_SenhaCNESUsuarioType'.,
cvc-type.3.1.3: The value '' of element 'ns1:Senha' is not valid

因此,Senha不能为空字符串。