1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
' Gambas class file
Public P As HttpClient
Public Sub P_Error()
LblInfo.Text = ("Error ") & P.Status
End
Public Sub Form_Open()
TextArea1.Text = ""
P = New HttpClient As "P"
End
Public Sub P_Connect()
LblInfo.Text = ("Waiting for reply...")
End
Public Sub P_Finished()
Dim sBuf As String
Dim MyLoop As Integer
LblInfo.Text = ("OK")
TextArea2.Insert(P.Headers.Join("\n") & "\n")
If Lof(P) Then
sBuf = Read #P, Lof(P)
TextArea1.Text = sBuf
Endif
If (InStr(sBuf, "<value><int>")) Then
sBuf = Mid(sBuf, InStr(sBuf, "<value><int>") + 12)
MyLoop = 1
Label6.Text = TextBox1.Text & " + " & TextBox2.Text & " = "
Do While Mid(sBuf, MyLoop, 1) <> "<"
Label6.Text = Label6.Text & Mid(sBuf, MyLoop, 1)
MyLoop = MyLoop + 1
Loop
If (InStr(sBuf, "<value><int>")) Then
sBuf = Mid(sBuf, InStr(sBuf, "<value><int>") + 12)
MyLoop = 1
Label7.Text = TextBox1.Text & " - " & TextBox2.Text & " = "
Do While Mid(sBuf, MyLoop, 1) <> "<"
Label7.Text = Label7.Text & Mid(sBuf, MyLoop, 1)
MyLoop = MyLoop + 1
Loop
Else
Message.Error(("Error"))
End If
Else
Message.Error(("Error"))
End If
End
Public Sub Button1_Click()
Dim sCad As String
LblInfo.Text = ("Connecting...")
TextBox1.Text = Val(Trim(TextBox1.Text))
TextBox2.Text = Val(Trim(TextBox2.Text))
Wait
TextArea1.Text = ""
sCad = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?>" & Chr(13) & Chr(10)
sCad = sCad & "<methodCall>" '& Chr(13) & Chr(10)
sCad = sCad & "<methodName>sample.sumAndDifference</methodName>" '& Chr(13) & Chr(10)
sCad = sCad & "<params>"
sCad = sCad & "<PARAM>"
sCad = sCad & "<value><i4>" & TextBox1.Text & "</i4></value>"
sCad = sCad & "</PARAM>"
sCad = sCad & "<PARAM>"
sCad = sCad & "<value><i4>" & TextBox2.Text & "</i4></value>"
sCad = sCad & "</PARAM>"
sCad = sCad & "</params>"
sCad = sCad & "</methodCall>"
If ChkProxy.Value Then
P.Proxy.Host = TxtProxy.Text
Else
P.Proxy.Host = ""
End If
P.URL = "dansoft.krasnokamensk.ru/xmlrpc-c-api/sample.php"
P.Post("text/xml", sCad)
End
Public Sub ChkProxy_Click()
TxtProxy.Enabled = ChkProxy.Value
End
|