以下是请求QQ号码是否在线功能的示例:
请求地址:http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx
请求参数:QQ号码
Sub Initialize On Error Goto errormsg Dim FromDateTime As New NotesDateTime("") '请求体 Dim XmlBody As String '请求结果 dim ResultXml As String 'web服务地址 Dim SrvUrl As String SrvUrl=|http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx| XmlBody=|<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <qqCheckOnline xmlns="http://WebXml.com.cn/"> <qqCode>997717740</qqCode> </qqCheckOnline> </soap:Body> </soap:Envelope>| '声明XmlHttp请求对象 Dim xmlhttp As Variant Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") Call xmlhttp.Open("Post",SrvUrl, False,"","") Call xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8") Call xmlhttp.SetRequestHeader ("SOAPAction","http://WebXml.com.cn/qqCheckOnline") Call xmlhttp.SetTimeOuts(1000000,1000000,1000000,1000000) Call xmlhttp.send(XmlBody)
'打印请求结果到浏览器 print xmlhttp.responseText Exit Sub errormsg: Msgbox "Rule Error:" & Str(Erl) & " " & Error End Sub
返回结果:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<qqCheckOnlineResponse xmlns="http://WebXml.com.cn/">
<qqCheckOnlineResult>Y</qqCheckOnlineResult>
</qqCheckOnlineResponse>
</soap:Body>
</soap:Envelope>