在 vb 脚本中测试 SOAP WSDL 是启动还是关闭?

Test if a SOAP WSDL is up or down in vb script?

我正在尝试验证 WSDL 是否在 运行 或 VB 脚本中是否正常。

如果我们在浏览器中打开 WSDL,如果我们在其中得到一个 XML,那么 WSDL 是 UP 并且 运行

如果 blank/timing out/not 响应,则 WSDL 已关闭

我想为此写一个VB脚本程序?

我在 VB 脚本中期待这样的事情 QTP/UFT 或 EXCEL VB 中的 运行 宏。

这个程序写在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?");
    }
}

此程序仅检查内容是否正在加载并决定是否运行正在加载

任何想法

像这样的东西应该有用。
我使用 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