如何在请求中通过 soap 保护数据传输?
How to secure datatransfer via soap in the request?
我使用 Soap 从 Web 服务获取数据。我采用的方法是发送带有密码和用户名的 HttpWebRequest。提供者给了我 https://www.myprovider.com
之类的东西,以及他们提供的方法的名称,例如 get_data_as_bytes
、get_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"
我使用 Soap 从 Web 服务获取数据。我采用的方法是发送带有密码和用户名的 HttpWebRequest。提供者给了我 https://www.myprovider.com
之类的东西,以及他们提供的方法的名称,例如 get_data_as_bytes
、get_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"