我正在尝试验证WSDL是否在VB脚本中运行或运行。
如果我们在浏览器中打开WSDL,如果我们得到一个XML,那么WSDL就是UP并且正在运行
如果它是空白/超时/没有响应则WSDL是DOWN
我想为此编写一个VB Script程序?
我期待在VB脚本中使用QTP / UFT或EXCEL VBA MACRO运行这样的东西。
该程序是用Java编写的
public static void main(String args[]) {
String wsdl = "http://lxomavnat005.dev.qintra.com:10301/icl/services/ICL_2_0?wsdl";
URL url = null;
URLConnection urlConnection = null;
try {
url = new URL(wsdl);
urlConnection = url.openConnection();
if (urlConnection.getContent() != null) {
System.out.println("GOOD URL");
} else {
System.out.println("BAD URL");
}
} catch (IOException ex) {
System.out
.println("Failed opening connection. Perhaps WS is not up?");
}
}
本程序只是检查内容是否正在加载并确定它是否正在运行
任何想法
答案 0 :(得分:0)
这样的事情应该有效 我使用SharePoint 2010 Web服务进行了测试。
' TestWSDL - Test if WSDL is up and running
Public Sub TestWSDL()
Dim oHttpRequest As Object
Dim oHttpResponse As Object
On Error GoTo Trap
Set oHttpRequest = CreateObject("Microsoft.XMLHTTP")
oHttpRequest.Open "GET", "http://domain/path/_vti_bin/UserGroup.asmx?wsdl", False
oHttpRequest.Send
If oHttpRequest.ReadyState = 4 Then
If oHttpRequest.Status = 200 Then
Set oHttpResponse = oHttpRequest.ResponseXML
If oHttpResponse Is Nothing Then
MsgBox "bad url"
Else
MsgBox "good url"
Set oHttpResponse = Nothing
End If
Else
MsgBox oHttpRequest.Status & " - " & oHttpRequest.StatusText
End If
Else
MsgBox oHttpRequest.ReadyState
End If
Trap:
If Err <> 0 Then
MsgBox Error(Err)
End If
Set oHttpRequest = Nothing
End Sub
以下内容类似,使用Microsoft WinHTTP Services v5.1而不是Microsoft XMLHTTP
Public Sub TestWinHTTP()
Dim oHttpRequest As Object
On Error GoTo Trap
Set oHttpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oHttpRequest.Open "GET", "http://domain/path/_vti_bin/UserGroup.asmx?wsdl", False
' Need to use SetCredentials OR SetAutoLogonPolicy
' Set specific username / password
'oHttpRequest.SetCredentials "username", "password", 0
' Use windows authentication
oHttpRequest.SetAutoLogonPolicy 0
' Set timeout values -- host, connect, send, receive
oHttpRequest.SetTimeouts 30000, 60000, 30000, 30000
oHttpRequest.Send
If oHttpRequest.Status = 200 Then
If oHttpRequest.ResponseText = "" Then
MsgBox "bad url"
Else
MsgBox "good url"
End If
Else
MsgBox "bad url"
End If
Trap:
If Err <> 0 Then
MsgBox Error(Err)
End If
Set oHttpRequest = Nothing
End Sub