php - 如何使用 Laravel 和 Soap 1.1 连接 Web 服务
问题描述
您好,我需要连接到 SOAP Web 服务才能从那里获取数据。SOAP 请求是:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDS4Response xmlns="http://tempuri.org/WAPSWS/WAPSWS">
<GetDS4Result>
<xsd:schema>schema</xsd:schema>xml</GetDS4Result>
</GetDS4Response>
</soap:Body>
</soap:Envelope>
我试试这个代码,但刀片上什么也没有
public function show()
{
$source = <<<SOURCE
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDS4 xmlns="http://tempuri.org/WAPSWS/WAPSWS">
<CommandString>select top 10 * from applpendingremark</CommandString>
</GetDS4>
</soap:Body>
</soap:Envelope>
SOURCE;
$xml = simplexml_load_string($source);
$xml->registerXPathNamespace('tempuri', 'http://moaqs.com/MOAQSWS/WAPSWS.asmx?op=GetDS4');
$elements = $xml->xpath('//soap:Envelope/soap:Body/tempuri:GetDS4/tempuri:GetDS4');
$result = json_encode($elements, true);
print_r($result);
return view('aa.aa',compact('result'));
}
提前致谢
解决方案
推荐阅读
- filesystems - 如何模拟 FatFS?
- amazon-web-services - AWS freeRtos“无法预置设备证书错误:48”
- javascript - 与打字稿语法混淆
- c - 为什么 zsh 会隐藏 ac 程序的错误输出?
- c - 在 C 中打印排序数组时得到奇怪的输出
- mysql - 如何使用 SQL 注入写入文件?
- python - 如何在 numpy 中添加多个矩阵?
- julia - 在 MacOS 上启动 Julia 1.1.1 桌面快捷方式时出现问题?
- python - 有哪些 pip 命令可以删除 pip 安装存储的多余空间?
- google-chrome-devtools - 如何将文件从我的文件系统添加到 chrome 检查元素开发工具?