解决方案如下:
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
在本例中,“flow.xml”文件可能如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<!-- your xml flow to be send via http -->
</root>