I am totally new with VB6 and REST architecture. Nevertheless I would like please to know if there is any HelloWorld example for a REST Client which invokes a RESTFul webService using Windows HTTP Services API. Many thanks in advance.
Asked
Active
Viewed 1,409 times
1
-
http://stackoverflow.com/help/how-to-ask – Rob Feb 27 '15 at 17:33
-
@Rob What's wrong with my inquirement ?! – sasuke Feb 27 '15 at 17:36
-
Did you read 'How to ask'? – Rob Feb 27 '15 at 19:38
-
A somewhat dated sample [here](https://github.com/wqweto/VbGcp). – wqw Feb 27 '15 at 20:02
-
Why not use msxml http://stackoverflow.com/questions/3516119/get-post-to-restful-web-service – MarkJ Mar 02 '15 at 21:44
1 Answers
0
Here's the solution :
Sub SendAsynchMessage()
Dim objHTTP As New WinHttp.WinHttpRequest
Dim doc As New MSXML2.DOMDocument
Dim root As MSXML2.IXMLDOMNode
Dim success As Boolean
Dim str As String
On Error GoTo ErrorHandler
success = doc.Load(App.Path & "\flow.xml")
Set root = doc.selectSingleNode("/root")
str = CStr(root.childNodes.Item(0).xml)
URL = "http://ipAddress:8081/messageAsynch"
objHTTP.Open "POST", url, False
objHTTP.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
objHTTP.Send (str)
Debug.Print objHTTP.Status
Debug.Print objHTTP.ResponseText
Exit Sub
ErrorHandler:
Dim E As ErrObject: Set E = Err
End Sub
The "flow.xml" file could look like in this case :
<?xml version="1.0" encoding="utf-8" ?>
<root>
<!-- your xml flow to be send via http -->
</root>

sasuke
- 145
- 1
- 10