微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 R 从 SOAP xml web 服务发送 SMS

如何解决使用 R 从 SOAP xml web 服务发送 SMS

我正在尝试使用 RCurl 包连接 SOAP/xml SMS Web 服务。 我的网络服务地址是http://sms.tums.ac.ir/Assembly/smsServices/SendReceive.asmx,发送短信的操作是http://sms.tums.ac.ir/Assembly/smsServices/SendReceive.asmx?op=SendSMS

以下是 SOAP 请求和响应示例:

请求:

POST /Assembly/smsServices/SendReceive.asmx HTTP/1.1
Host: sms.tums.ac.ir
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/SendSMS"

<?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>
    <SendSMS xmlns="http://tempuri.org/">
      <userName>string</userName>
      <password>string</password>
      <predicateID>int</predicateID>
      <sendSMSData>
        <ID>int</ID>
        <Priority>normal or Medium or High or VeryHigh</Priority>
        <MessageText>string</MessageText>
        <Destinations>
          <ServiceDestination>
            <ID>int</ID>
            <Registerer>string</Registerer>
            <Identifier>long</Identifier>
            <Status>int</Status>
            <RetryCount>int</RetryCount>
            <RetryProc>boolean</RetryProc>
            <State>string</State>
            <Destination>string</Destination>
            <ContactName>string</ContactName>
            <Mode>UnkNown or Manual or Person or Company</Mode>
          </ServiceDestination>
          <ServiceDestination>
            <ID>int</ID>
            <Registerer>string</Registerer>
            <Identifier>long</Identifier>
            <Status>int</Status>
            <RetryCount>int</RetryCount>
            <RetryProc>boolean</RetryProc>
            <State>string</State>
            <Destination>string</Destination>
            <ContactName>string</ContactName>
            <Mode>UnkNown or Manual or Person or Company</Mode>
          </ServiceDestination>
        </Destinations>
        <ServiceNumber>string</ServiceNumber>
        <SendDate>dateTime</SendDate>
        <FlashMSG>boolean</FlashMSG>
      </sendSMSData>
    </SendSMS>
  </soap:Body>
</soap:Envelope>

回应

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>
    <SendSMSResponse xmlns="http://tempuri.org/">
      <SendSMSResult>
        <Validation>
          <boolean>boolean</boolean>
          <boolean>boolean</boolean>
        </Validation>
      </SendSMSResult>
    </SendSMSResponse>
  </soap:Body>
</soap:Envelope>

我在 R 中使用以下代码连接网络服务以发送短信:

headerFields =
  c(Host= "sms.tums.ac.ir",Content-Type=  'text/xml ;charset="utf-8"',SOAPAction= "http://sms.tums.ac.ir/Assembly/smsServices/SendReceive.asmx?op=SendSMS")


body = '<?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope 
  <SendSMS 
  <userName>USERNAME</userName>
  <password>PASSWORD</password>
  <predicateID>0</predicateID>
  <sendSMSData>
  <ID>123</ID>
  <Priority>normal</Priority>
  <MessageText>test hadi</MessageText>
  <Destinations>
  <ServiceDestination>
  <ID>123</ID>
  <Registerer>test reg</Registerer>
  <Identifier>12345</Identifier>
  <Status>int</Status>
  <Destination>09189061738</Destination>
  <ContactName>mahdi</ContactName>
  <Mode>Person</Mode>
  </ServiceDestination>
  </Destinations>
  <ServiceNumber>30004034</ServiceNumber>
  </sendSMSData>
  </SendSMS>
  </soap:Body>
  </soap:Envelope>'

curlPerform(url = "http://sms.tums.ac.ir/Assembly/smsServices/SendReceive.asmx",httpheader = headerFields,postfields = body
)

但是代码输出是:

OK 
 0  

什么都没做...

我是使用 xml 和 SOAP 网络服务的初学者,请帮助我如何在 R 中使用我的网络服务发送短信。我没有找到类似的代码,旨在使用 xml 网络服务在 R 中发送短信。

提前致谢...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。