Yesterday I received a request to implement some Web Services for a legacy application which is written in Classic ASP. Well, I’ve nothing against using Microsoft .NET to achieve this task, but once the application has a good design and the classes are already there, shouldn’t it be easiest to take the VBScript code and use it to increase my productivity? IMHO the answer is yes.

Well, in summary this article covers the following problem: “How to create a Web Service based in Classic VBScript ASP 3.0 classes using MS SOAP Toolkit 3.0 and Visual Basic 6.0 to work in a IIS 6.0 (Windows 2003) environment?” and the reason why I’m writing this is because I had a little hard time to solve it. I think it mainly happened because the MS SOAP Toolkit was already discontinued when Microsoft released Windows 2003 and the .NET Framework was at it’s climax in the hightech world. So, there isn’t too many material available.

Ah, one more note: I’ve no intention to describe or introduct any of the concepts involved in this task, since you can simply google it an get a lot of results about the definitions. That’s why I’m choosing a very practical way to present this. Ok, that said, let’s begin.

Deploying Web Services

The first problem I’ve found was related with Microsoft Java Virtual Machine. VS6 just don’t work right if you install it in a machine with the latest Sun Virtual Machine, even setting the default Virtual Machine to MSVM. The unique solution I found here is to install VS6 right after a fresh WinXP installation. Well, this isn’t a real problem since you can always load a virtual machine based in your fresh OS VDI. If you don’t have a fresh OS VDI, maybe you should start thinking about using .NET anyway.

Once you have both VS6 and MSSOAP Toolkit ready you can open Microsoft Visual Basic and start a new ActiveX DLL, rename the project to your object name, rename the class that’s already there, add methods and append other classes. This is how my service looks like:

Creating the Web Service

Make a dll and upload it to your server. Next step is to open a command in the server and register that dll (eg. regsvr32 myservice.dll), then open the SOAP Toolkit 3.0 WSDL Generator, click “Next >” twice, give a name to your service, click “Select COM object” and browse your dll.

Select the COM .dll to analyze

Click “Next >” and select the classes and methods you want to make available through the web service.

Select the services you would like to expose

Click “Next >” again and fill out the URI where you are going to distribute your web service. Don’t change the type from ISAPI to ASP because the first have a better performance and I’ll use it in the rest of the article.

SOAP listener information

Change all “” entries with your WS Address.

Specify URIs

Specify the location where you want the generator to save the files.

Specify the location for the new WSDL and WSML files

Click “Next >” then “Finish” and voilá both Web Services Description Language and Web Services Meta Language should be in the location you selected before.

Now, since Windows 2003 has some additional security features over Windows 2000, you have to allow the SOAP Toolkit 3.0 to work. This is done in the Web Service Extensions from the IIS.

Set extension status to allowed

The last but not least, create the virtual directory and map the .WSDL extension to the SOAPIS30.dll ( Don’t forget to use the double quotes! )

Map .WSDL extension to SOAPIS30

That’s it! If you have done everything right, the result should be a clone of this service

Consuming Web Services

Once you finish to host the Web Service, it’s time to test it before starting to distribute it and it’s a very easy task. Create an ASP page to do the unit test, mine is:

dim Ws, sum, difference, product, quotient
set Ws = Server.createObject("MSSOAP.SoapClient30")
Ws.clientProperty("ServerHTTPRequest") = true
sum = Ws.add(6, 2)
difference = Ws.subtract(6, 2)
product = Ws.multiply(6, 2)
quotient = Ws.divide(6, 2)
set Ws = nothing
Response.write "6 + 2 = " & sum & "<br />" & vbCrLf
Response.write "6 - 2 = " & difference & "<br />" & vbCrLf
Response.write "6 * 2 = " & product & "<br />" & vbCrLf
Response.write "6 / 2 = " & quotient & "<br />" & vbCrLf

Open a browser and execute the page above. If everything is fine you should be now reading:

6 + 2 = 8
6 - 2 = 4
6 * 2 = 12
6 / 2 = 3

That’s it, I hope you have enjoyed this entry. Have a good work ;D