-2

我想从我的 vb 6.0 代码中调用 java servlet。我已经在远程机器上使用了 serverlet 的 URL,并在程序执行后显示了消息。

4

2 回答 2

0
Private Sub Command3_Click()
Dim req As WinHttp.WinHttpRequest
Dim buffer As Variant
Set req = New WinHttp.WinHttpRequest
req.SetTimeouts 1800000, 1800000, 1800000, 1800000
req.Open "POST", "http://www.google.co.in", False
buffer = "tusharp 0"
req.Send cmbuffer
Debug.Print req.ResponseText

End Sub

试试这个.....

于 2013-05-29T04:52:45.520 回答
0

使用以下一堆代码,您可以简单地使用 URL 调用 servlet。您可以通过适当的方法传递参数。

**Private Function ExecuteSQL(ByVal sSQL As String, ByVal bResultSet As Boolean) As String
Dim http As Object
Dim strURL As String
Dim strPostData As String
Dim strHeader As String
Dim strResponse As String

On Error GoTo Err

Screen.MousePointer = vbHourglass
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")

strPostData = "?Command=" & IIf(bResultSet, "SELECT", "UPDATE") & "&SQL=" & sSQL

strURL = "http://localhost:8080/FirstProject/DBConnector" & strPostData
http.setTimeouts 10000, 10000, 10000, 10000 'For some reason times out sooner than this sometimes

http.Open "POST", strURL, False
http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send strPostData
strResponse = http.ResponseText

Screen.MousePointer = vbDefault
ExecuteSQL = strResponse
Exit Function
于 2015-04-30T09:12:20.080 回答