---
title: "用VBS脚本测试WebService"
author: "bardo"
date: "2010-05-04T21:43:41Z"
tags: []
categories: ["编程语言"]
slug: "vbs-webservice"
draft: false
lastmod: "2010-05-04T21:43:41Z"
id: 659037
url: "https://bardo.iteye.com/blog/659037"
---

用VBS脚本测试WEBSERVICE ( 2006-11-14 8:54 )

注：以下代码需要客户端安装SOAP！！

'*********************************************************************************************
'WEB SERVICE客户端可连通测试工具----版本:1.0       AUTHOR: BARDO
'本工具可以直接运行,运行前,注意修改以下参数:
'1,如果是SOAP2.0,则将第10行代码改为:set SOAPClient = createobject(&quot;MSSOAP.SOAPClient&quot;)
'2,修改第12行中的URL,指向到所要测试的WEB SERVICE的WSDL
'3,修改完成后保存双击运行,如果出错,点OK,可以看到详细错误信息,如能连通,则返回Soap Sucess!
'4,注意如果此文件扩展名不是VBS,则要改为VBS,才能运行.
'*********************************************************************************************
Dim SOAPClient,ResultLogin,strTask
set SOAPClient = createobject(&quot;MSSOAP.SOAPClient30&quot;)
On Error Resume Next
SOAPClient.mssoapinit(&quot;[http://ServiceServer/ServiceName.jws?wsdl](http://ServiceServer/ServiceName.jws?wsdl)&quot;) 
  If err then
    wscriptt.echo SOAPClient.faultString          '如果连不上,先返回失败串,
    wscriptt.echo SOAPClient.detail               '再返回失败详情
  Else
    wscriptt.echo &quot;mssoapinit Sucess!&quot;                  '连上以后返回
  End if

SOAPClient.ConnectorProperty(&quot;Timeout&quot;) = &quot;30000&quot;    ' sets to 30 secs
If err then
    wscriptt.echo SOAPClient.faultString         '如果连不上,先返回失败串,
    wscriptt.echo SOAPClient.detail               '再返回失败详情
  Else
    wscriptt.echo &quot;Soap setTimeout Sucess!&quot;                  '连上以后返回
  End if
ResultLogin = SOAPClient.runYourMethod(&quot;username&quot;, &quot;password&quot;)
If err then
    wscriptt.echo SOAPClient.faultString          '如果连不上,先返回失败串,
    wscriptt.echo SOAPClient.detail               '再返回失败详情
Else
    wscriptt.echo &quot;Soap runYourMethod Sucess!&quot;                  '连上以后返回
End if