【问题标题】:How to secure datatransfer via soap in the request?如何在请求中通过soap保护数据传输?
【发布时间】:2015-04-17 01:14:44
【问题描述】:

我使用 Soap 从 Web 服务获取数据。我的方式是发送一个带有密码和用户名的 HttpWebRequest。提供者给了我https://www.myprovider.com 之类的东西,以及他们提供的方法的名称,例如get_data_as_bytesget_data_as_XML 等等。我现在的问题是,这个过程是否安全,因为我没有代码来解码任何在我看来通过互联网未加密的数据。还是我必须在 SOAP 文件中设置一些东西来请求加密?

SOAP 的构建方式如下:

Dim soapStr As String = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbCr & vbLf & "                <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""" & vbCr & vbLf & "                   xmlns:xsd=""http://www.w3.org/2001/XMLSchema""" & vbCr & vbLf & "                   xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & vbCr & vbLf & "                  <soap:Body>" & vbCr & vbLf & "                    <{0} xmlns=""http://tempuri.org/"">" & vbCr & vbLf & "                      {1}" & vbCr & vbLf & "                    </{0}>" & vbCr & vbLf & "                  </soap:Body>" & vbCr & vbLf & "                </soap:Envelope>"

Dim req As HttpWebRequest = DirectCast(WebRequest.Create(Url), HttpWebRequest)
req.Headers.Add("SOAPAction", (Convert.ToString("""http://tempuri.org/") & methodName) + """")
req.ContentType = "text/xml;charset=""utf-8"""
req.Accept = "text/xml"
req.Method = "POST"

【问题讨论】:

    标签: .net security soap httpwebrequest


    【解决方案1】:

    对于HttpWebRequest,您可以将协议指定为https 以使用SSL/TLS。将您的 SOAPAction URL 设为 https://tempuri.org/ 应该可以。

    PS:在 Windows 上,您可以安装 netmonFiddler 以查看每条消息使用的协议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 2017-01-22
      • 1970-01-01
      • 1970-01-01
      • 2016-01-13
      • 1970-01-01
      相关资源
      最近更新 更多