【问题标题】:need to send messages through soap requests需要通过soap请求发送消息
【发布时间】:2021-03-29 02:01:48
【问题描述】:

我有一个 XML 请求,但我不知道如何通过该soap 请求发送消息。我的 XML 请求文件结构如下所示。

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://schemas.test.com/xsd/kannel/handler/v1/" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header>
<testsms:authData xmlns:testsms="http://testsms.com/">
<testsms:user>username</testsms:user>
<testsms:key>password</testsms:key>
</testsms:authData>
</soapenv:Header>
<soapenv:Body>
<v1:SMSRequest>
<v1:requestData>
<v1:outSms>message content</v1:outSms>
<v1:recepient>81720233436</v1:recepient>
<v1:depCode>dept code</v1:depCode>
<v1:smscId/>
<v1:billable/>
</v1:requestData>
</v1:SMSRequest>
</soapenv:Body>
</soapenv:Envelope>

我需要通过这个肥皂请求发送消息。谁能帮我?可以使用 PHP(Laravel) 或 NodeJS。我有一个请求网址。

【问题讨论】:

  • 尝试将内容类型标头设置为 text/xml 并将此 XML 作为字符串发送到正文中。
  • @OscarVicentePerez 我需要在 PHP 或 NodeJS 中使用这个请求,就像我们使用 rest api 一样。
  • 是的,只需发送 xml 而不是 json 并更改内容类型标头。这只是一个类似于 REST 的 HTTP 请求。

标签: javascript php node.js laravel soap


【解决方案1】:

我建议您阅读更多有关 Soap 协议 here 的内容,以便您对要遵循的语法和标签有一个基本的了解。

接下来在 Laravel 中使用 PHP SoapClient 或者在 NodeJS 中使用 npm 包Soap,这完全取决于您根据自己的熟悉程度来选择框架。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 2017-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多