由于对RESTful Web服务的调用实际上只是一种特定的HTTP请求,因此您至少可以使用Microsoft XML库向Web服务发送HTTP请求并解析它返回的任何内容 . 例如,当我运行以下VBA代码时
' VBA project Reference required:
' Microsoft XML, v3.0
Dim httpReq As New MSXML2.ServerXMLHTTP
httpReq.Open "GET", "http://whois.arin.net/rest/poc/KOSTE-ARIN", False
httpReq.send
Dim response As String
response = httpReq.responseText
Debug.Print response
字符串变量 response 包含对我的请求的XML响应 . 它看起来像这样(在重新格式化以获得可读性之后):
xmlns:ns3="http://www.arin.net/whoisrws/netref/v2" termsOfUse="https://www.arin.net/whois_tou.html"
inaccuracyReportUrl="http://www.arin.net/public/whoisinaccuracy/index.xhtml">
2009-10-02T11:54:45-04:00
http://whois.arin.net/rest/poc/KOSTE-ARIN
Chantilly
ARIN
US
USA
UNITED STATES
1
Mark
KOSTE-ARIN
Kosters
markk@kosters.net
markk@bjmk.com
inaccuracyReportUrl="http://www.arin.net/public/whoisinaccuracy/index.xhtml">
false
+ 1-703-227-9870
Office
O
20151
I'm really MAK21-ARIN
VA
3635 Concorde Parkway
2015-05-26T11:36:55-04:00
您的Web服务返回的内容可能看起来有些不同 . 或者,与上面的ARIN whois RWS一样,您可以选择多种数据格式; XML只是默认值 . 我原本可以请求使用明文回复
httpReq.Open "GET", "http://whois.arin.net/rest/poc/KOSTE-ARIN.txt", False
在这种情况下 response 将包含
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#
Name: Kosters, Mark
Handle: KOSTE-ARIN
Company: ARIN
Address: 3635 Concorde Parkway
City: Chantilly
StateProv: VA
PostalCode: 20151
Country: US
RegDate: 2009-10-02
Updated: 2015-05-26
Comment: I'm really MAK21-ARIN
Phone: +1-703-227-9870 (Office)
Email: markk@bjmk.com
Email: markk@kosters.net
Ref: http://whois.arin.net/rest/poc/KOSTE-ARIN
#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/whois_tou.html
#