Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共9 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]关于https的问题,请问以下代码狐表中怎么写?

1楼
km007 发表于:2024/6/30 1:08:00


        If host.Contains("https://") Then
            ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CheckValidationResult)  
            httpRequest = CType(WebRequest.CreateDefault(New Uri(url)), HttpWebRequest)
        Else
            httpRequest = CType(WebRequest.Create(url), HttpWebRequest)
        End If


请上上面红色字体的 狐表代码 应该怎么写呢?


[此贴子已经被作者于2024/6/30 21:56:23编辑过]
2楼
km007 发表于:2024/6/30 21:56:00
求助 求助
3楼
有点蓝 发表于:2024/6/30 22:30:00
补上命名空间
Net.ServicePointManager.ServerCertificateValidationCallback = New Net.Security.RemoteCertificateValidationCallback(AddressOf CheckValidationResult)
httpRequest = CType(Net.WebRequest.CreateDefault(New Uri(url)), Net.HttpWebRequest)
[此贴子已经被作者于2024/6/30 22:30:21编辑过]
4楼
km007 发表于:2024/6/30 23:05:00
以下是C#转.net后的代码

Class SurroundingClass
    Private Const host As String = "https://ali-deliver.showapi.com"
    Private Const path As String = "/showapi_expInfo"
    Private Const method As String = "GET"
    Private Const appcode As String = "你自己的AppCode"

    Private Shared Sub Main(ByVal args As String())
        Dim querys As String = "com=zhongtong&nu=535962308717&receiverPhone=receiverPhone&senderPhone=senderPhone"
        Dim bodys As String = ""
        Dim url As String = host + path
        Dim httpRequest As HttpWebRequest = Nothing
        Dim httpResponse As HttpWebResponse = Nothing

        If 0 < querys.Length Then
            url = url & "?" + querys
        End If

        If host.Contains("https://") Then
            ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CheckValidationResult)
            httpRequest = CType(WebRequest.CreateDefault(New Uri(url)), HttpWebRequest)
        Else
            httpRequest = CType(WebRequest.Create(url), HttpWebRequest)
        End If

        httpRequest.Method = method
        httpRequest.Headers.Add("Authorization", "APPCODE " & appcode)

        If 0 < bodys.Length Then
            Dim data As Byte() = Encoding.UTF8.GetBytes(bodys)

            Using stream As Stream = httpRequest.GetRequestStream()
                stream.Write(data, 0, data.Length)
            End Using
        End If

        Try
            httpResponse = CType(httpRequest.GetResponse(), HttpWebResponse)
        Catch ex As WebException
            httpResponse = CType(ex.Response, HttpWebResponse)
        End Try

        Console.WriteLine(httpResponse.StatusCode)
        Console.WriteLine(httpResponse.Method)
        Console.WriteLine(httpResponse.Headers)
        Dim st As Stream = httpResponse.GetResponseStream()
        Dim reader As StreamReader = New StreamReader(st, Encoding.GetEncoding("utf-8"))
        Console.WriteLine(reader.ReadToEnd())
        Console.WriteLine(vbLf)
    End Sub

    Public Shared Function CheckValidationResult(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal errors As SslPolicyErrors) As Boolean
        Return True
    End Function
End Class
5楼
有点蓝 发表于:2024/6/30 23:12:00
1、全部补上命名空间
2、所有Private 改为 Public 
6楼
km007 发表于:2024/7/1 1:39:00
但是 这个没有调用sdk的
7楼
有点蓝 发表于:2024/7/1 8:26:00
哪有啥问题?
8楼
km007 发表于:2024/7/1 17:43:00
不是调用SDK才需要设置 命名空间 的吗?

9楼
有点蓝 发表于:2024/7/1 20:08:00
错误!所有.net的类型都需要命名空间,Foxtable只是使用了.net部分功能,所以并没有把所有.net的dll以及对应的命名空间都引用到Foxtable里,因此需要用到Foxtable没有的功能的时候基本都需要添加对应的命名空间
共9 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02734 s, 2 queries.