一种方法是创建 WebGet wcf 服务,服务将返回 adorecordset xml,在宏上您可以使用以下代码获取记录集
Public Function GetRSFromString(sXML As String) As Object
Dim oStream As Object, oRecordset As Object
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.WriteText sXML
oStream.Position = 0
Set oRecordset = CreateObject("ADODB.Recordset")
oRecordset.Open oStream
oStream.Close
Set oStream = Nothing
Set GetRSFromString = oRecordset
Set oRecordset = Nothing
End Function
Public Function GetSoapRequest()
Dim strResult As String
Dim xmlhtp As Object, xmlDoc As Object, oRecordSetFromXML As Object
Set xmlhtp = CreateObject("msxml2.xmlhttp.6.0")
With xmlhtp
.Open "get", "http://[server]/ServiceName.svc/FunctionName", False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.Send
Set xmlDoc = CreateObject("msxml2.DOMDocument.6.0")
strResult = .responseText
xmlDoc.loadXML strResult
Set oRecordSetFromXML = AdoFunction .GetRSFromString(xmlDoc.Text)
End With
Set xmlDoc = Nothing
Set xmlhtp = Nothing
End Function