测试一个SOAP WSDL在vb脚本中是up还是down? [英] Test if a SOAP WSDL is up or down in vb script?
问题描述
如果我们在浏览器中打开WSDL,如果我们得到一个XML,那么WSDL是UP和运行
如果它是空白/超时/不响应,那么WSDL是DOWN
我想为此编写一个VB脚本程序?
我期待VB脚本中的某些操作可以在QTP / UFT或EXCEL VBA宏中运行。
此程序用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(打开连接失败,也许WS不起来? );
}
}
此程序只是检查内容是否加载,决定是否运行
任何想法
这应该工作。
我使用SharePoint 2010 Web服务进行测试。
'TestWSDL - 测试WSDL正在运行
公共Sub TestWSDL()
Dim oHttpRequest As Object
Dim oHttpResponse As Object
错误GoTo陷阱
设置oHttpRequest = CreateObject(Microsoft.XMLHTTP)
oHttpRequest.OpenGET,http://domain/path/_vti_bin/UserGroup.asmx?wsdl,False
oHttpRequest.Send
如果oHttpRequest.ReadyState = 4然后
如果oHttpRequest.Status = 200然后
设置oHttpResponse = oHttpRequest.ResponseXML
如果oHttpResponse不是,然后
MsgBoxbad url
Else
MsgBoxgood url
Set oHttpResponse = Nothing
End If
Else
MsgBox oHttpRequest.Status& - & oHttpRequest.StatusText
如果
Else
MsgBox oHttpRequest.ReadyState
End If
陷阱:
如果Err<> 0然后
MsgBox错误(错误)
结束如果
设置oHttpRequest =没有
结束Sub
以下是类似的,使用 Microsoft WinHTTP Services v5.1 而不是Microsoft XMLHTTP
公开Sub TestWinHTTP()
Dim oHttpRequest As Object
错误GoTo陷阱
设置oHttpRequest = CreateObject(WinHttp.WinHttpRequest.5.1)
oHttpRequest 。打开GET,http://domain/path/_vti_bin/UserGroup.asmx?wsdl,False
'需要使用SetCredentials或SetAutoLogonPolicy
'设置特定的用户名/密码
'oHttpRequest.SetCredentialsusername,password,0
'使用Windows身份验证
oHttpRequest.SetAutoLogonPolicy 0
'设置超时值 - - 主机,连接,发送,接收
oHttpRequest.SetTimeouts 30000,600,30000,30000
oHttpRequest.Send
如果oHttpRequest.Status = 200然后
如果oHttpRequest.ResponseText =然后
MsgBoxbad url
Else
MsgBoxgood url
End If
Else
MsgBoxbad url
End If
陷阱:
如果Err 0然后
MsgBox错误(错误)
结束如果
设置oHttpRequest =没有
结束Sub
I am trying to Verify if the WSDL is UP and Running or NOT in VB Script.
IF we open the WSDL in browser, if we get an XML in that then the WSDL is UP and Running
If it is blank/timing out/not responding then WSDL is DOWN
I want to write a VB Script program for this?
I was expecting some thing like this in VB Script to run in QTP/UFT or EXCEL VBA MACRO.
This program is written in 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?");
}
}
This Program just check the content is loading or not and decides if it running or not
Any Ideas
Something like this should work.
I tested using a SharePoint 2010 web service.
' 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
Following is similar, using Microsoft WinHTTP Services v5.1 instead of 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
这篇关于测试一个SOAP WSDL在vb脚本中是up还是down?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!