gpt4 book ai didi

laravel - 如何在 Laravel 中发出 SOAP 请求?

转载 作者:行者123 更新时间:2023-12-03 08:19:39 25 4
gpt4 key购买 nike

enter image description here

此请求需要基本身份验证:用户名和密码。

enter image description here

具有两个字段的 header 。

enter image description here

和 xml 正文。

此 API 已在 Postman 中测试运行。但我不确定如何在 Laravel 中实现此功能,我之前只使用 JSON。

有什么建议我可以如何开始吗?或者我可以使用任何包?

最佳答案

您可以使用http post

 $http=Http::withHeaders([
'Content-Type'=>'application/xml',
'SOAPAction'=>'balance'
])->post(url,$xmlBodyContent);



return response($http->body())
->withHeaders([
'Content-Type' => 'text/xml'
]);

另一种方法是使用withBody方法

$http=Http::withHeaders([
'Content-Type'=>'application/xml',
'SOAPAction'=>'balance'
])->withBody($xmlBodyContent,"text/xml")->post(url);

用于 xml 文档表示法引用:https://www.php.net/manual/en/simplexml.examples-basic.php

要生成 xml 数组,请使用 array-to-xml

关于laravel - 如何在 Laravel 中发出 SOAP 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68281794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com