The VBScript Network and Systems Administrator's Cafe

Oct 16 2008   2:53AM GMT

Consuming and using a web service from within VBScript to create a WHOIS tool

Jerry Lees Jerry Lees Profile: Jerry Lees

Recently I posted a list of web services at a site that were public web services, in the article entitled A Great list of FREE publicly available Web Services. In looking through them I noticed one that would be useful- a WHOIS web service!

Please keep in mind that this script uses a PUBLIC and FREE web service to preform the heart of it’s work… it might not be always available and that is out of both our control. However, the code will work, with minor changes where noted for any other web service.

First some background on a web service. When you consume (use) a web service, you call it like you would any other class or function, with a .functionname after the object is created as an instance.

The MSSOAP.SOAPClient line below creates a SOAP object, and the .MSSOAPINIT creates an instance of your web service in that object. Then, in this case the .whois  call actually makes it preform the functions on the remote system. The remote system then returns back the value from the function to you just as if a local function were called.

Pretty cool stuff! So, here is the code to call a web service from VBScript!
dim SOAPClient, Response
‘create the SOAP object
Set SOAPClient = createobject(“MSSOAP.SOAPClient”)
on error resume Next
‘create a instance of the WHIOIS web service
SOAPClient.mssoapinit(“
http://www.ecubicle.net/whois_service.asmx?WSDL“)
  ‘ check for errors… deal with them if they occur by reporting them
  if err Then
    wscript.echo SOAPClient.faultString
    wscript.echo SOAPClient.detail
  end If

‘this next line is where we actually CALL the web service
Response = SOAPClient.Whois(“whois.networksolutions.com”, 43, “networksolutions.com”)

‘fix up network solutions’ HTML responses to whois queries. why do they have to be difficult?
Response = replace(Response,”<br/>”,VbCrLf)
Response = replace(Response,”<BR/>”,VbCrLf)

‘ echo the response recieved (since it’s a string)
wscript.echo Response

‘ check for errors… deal with them if they occur by reporting them
  if err Then
    wscript.echo SOAPClient.faultString
    wscript.echo SOAPClient.detail
  End If

1  Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • manish88

    hi,

    i have tried this code by copy paste in notepad file and saved it as .vbs, while runnig throwing error, can't create object of MSSOAP.SOAPClient

    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: