作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
此请求需要基本身份验证:用户名和密码。
具有两个字段的 header 。
和 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/
我是一名优秀的程序员,十分优秀!