php - 将属性传递给soap Header
问题描述
我正在尝试在肥皂请求下重新创建
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:data="http://test.gbd.chdb.test.net">
<soapenv:Header>
<userId>5647775-b7d7-4a45-9570-654116547654</userId>
</soapenv:Header>
<soapenv:Body>
<data:getPerson>
<!--Optional:-->
<iin>700521700054</iin>
<!--Optional:-->
<consentConfirmed>true</consentConfirmed>
</data:getPerson>
</soapenv:Body>
</soapenv:Envelope>
使用下面的 php 脚本
$opts = array(some attributes);
$soap_client = new \SoapClient(null,
array(
'location' => 'https://test.test.net/testServices/PersonDetailsImplService',
'uri' => 'http://test.gbd.chdb.test.net',
'login' => 'XXXXXXX',
'password' => 'YYYYYYY',
'cache_wsdl' => WSDL_CACHE_NONE,
'soap_version'=> SOAP_1_1,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'trace' => true,
'exceptions' => true,
'stream_context' => stream_context_create($opts)
)
);
$auth = new \stdClass();
$auth->userId = '5647775-b7d7-4a45-9570-654116547654';
$header = new \SoapHeader('http://test.gbd.chdb.test.net', 'Header', $auth);
$soap_client->__setSoapHeaders($header);
$result = $soap_client->getPerson();
每次执行此操作时,我都会收到响应“userId 字段丢失”。不确定我做错了什么,因为我在下面的脚本中设置 Header 属性并通过 __setSoapHeaders 将标题设置为我的 SoapClient。
几天来一直在研究它,并在网上浏览了大量文章 - 仍然没有成功。任何帮助都将受到高度重视。
解决方案
推荐阅读
- python - 单击重置按钮(重置在 OptionMenus 上所做的选择)后,OptionMenu 对其他 OptionMenus 的依赖不起作用
- python - 通过符号链接运行 python 脚本不允许编写小 L
- python - 为什么matplotlib Ylabel在图上方返回字符串线
- python-3.x - 重写 __repr__ 'TypeError-expected 0 arguments, got 1' 时出错
- reactjs - 反应条件组件渲染
- meson-build - 介子不产生任何二进制文件
- ruby-on-rails - Ruby on rails 错误在任何来源中都找不到 rake-13.0.3
- flutter - flutter_reactive_ble - 如何在订阅前检查设备是否已连接
- initialization - 在 VHDL 中分配给端口的初始化端口/信号的优先级
- php - 累积布局移位 (CLS) 问题。在 wordpress 主题中