php - 尝试连接到 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();
} });
我将不胜感激任何帮助。提前致谢
解决方案
来自 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
不能是空字符串。
推荐阅读
- asp.net-core - 在 asp.net core 3.1+ 中使用多个中间件进行身份验证和授权
- java - Java String.contains() 无法正常工作
- amazon-cloudformation - AWS MediaLive Cloudformation Fn::GetAtt 获取数组值
- c - 我怎样才能为“月/日”写一个正确的函数而不是我写的?
- javascript - 如何用java脚本隐藏div?
- java - tomcat、Java Servlet、Apache Netbeans 中的 404 错误
- kotlin - RxJava在处理后一直在发射项目,如何正确处理?
- elasticsearch - Elastic APM - 在 C# 代理库中使用 traceparent/trace_id 创建事务/跨度
- python-3.x - Discord py 为每个循环创建一个新的 tasks.loop 对象
- reactjs - 如何在蚂蚁设计中制作芯片组件的模拟/或如何管理图标以达到类似的结果?