VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
As the title says, one can configure the IIS (the MS-WebServer-Instance that comes with each Win-Installation)
in a way, that allows convenient roundtrip-debugging of serverside code, when it is contained in an AX-Dll-Project.
For that, one has to setup the VB6-IDE, to load and run a VB6-ProjectGroup (defined in a *.vbg-File) -
but more on that later...
First, to the setup of a *local* (on your Dev-Machine) running IIS-instance, to make that possible...
The following assumes that you already *have* installed a Dev-machine-local IIS-instance (over Programs-and-Features),
and didn't forget to check-in the support for "classic-ASP" in the Install-Options (which is a requirement).
Now, what's needed in addition, to make interaction with the (32Bit-) Dll-Binaries of VB6 possible,
can be done by changing a few DefaultAppPool-settings in the IIS-Manager
(which one can find either in the StartMenu, or by explicitely starting it from (usually) C:\WINDOWS\system32\inetsrv\IIS.msc )
Once the InetMgr was started up,
- select (in the TreeView to the Left) the ApplicationPools-Entry
- followed by right-clicking (in the main-area of the Dialog) the DefaultAppPool
- choose the "Extended Settings"-entry from the Menu
Now you will have to change two things in the upcoming Dialog:
- activate the "32Bit-Ness" of the AppPool (it's one of the Top-Entries)
- then set your own User-Identity (the credentials you use also for your Windows-Login) as the one, the AppPool-Process shall run under
Press OK in the Dialog.
Ok, what now remains is, to tell the IIS-instance, to use that new AppPool-Identity as the Default-Auth-mechanism for anonymous requests:
- select (in the TreeView to the Left) the Root-Entry
- doubleclick the Authentication-Icon in the main-area
- now right click "Anonymous Authentication" in the main-area
- and select "Edit" in the Context-Menu
- now choose "Identity of the Application-Pool" in the upcoming Dialog
Press OK in the Dialog.
Now restart the IIS-instance (on the restart-links on the right-hand-side) -
and we are all set to continue with the VB6-IDE (the configuration of the debuggable ProjectGroup).
... to be continued ...
Olaf
Last edited by Schmidt; Sep 29th, 2018 at 10:54 AM.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
It may be worth noting that when you install IIS with ASP support the process completes the installation of VB6 components. This allows you to create a new IIS Application Project.
You'll want to follow the configration steps given above to make this work properly in IIS. I haven't tried a Make (build) yet or tried a debugging session but all of the pieces seem to be in place even on Windows 10 (IIS 10).
A downside of IIS Applications (WebClasses) is that adoption was slow, much as you still find people using VB5's DAO today. When ASP.Net took this concept Microsoft started saying WebClasses were no longer supported... though it is starting to look as if they may still work fine.
But as a result there were never a lot of 3rd party published samples or tutorials of any substance. You need to take the original Microsoft VB6 class (rare now, and costly) or else crack the books from that era and the VB6 documentation from the October 2001 edition of the MSDN Library CDs.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
I should perhaps mention (since dile brought that up), that this thread is *not* trying to explain, how the "WebClasses"-ProjectType of VB6 will work
(which was primarily used, to ease the development of dynamic WebPages for Browser-Clients).
Instead this series will focus on, how a "full-blown and rich VB6-Desktop-Client-App" can be developed,
which uses the IIS only as a plain (non HTML-delivering) Application-Server...
The http-based RPCs we will set-up now, are merely an elegant means, to transport "arbitrary binary data" back and forth -
whilst communicating with such an AppServer-Instance in an easy (and debuggable) manner ...
(by wrapping-up a debuggable "ServerLib.dll"-Project in a VB6-ProjectGroup, together with a normal StdExe-ClientProject).
Ok, here the first - and very "bare bones" - Demo-Zip: RPCTest_Simple.zip
Please unzip its contents into a Development-Folder of your choice
(on the same machine, you've previously set-up the IIS-instance - as described in the Opener-Post).
ASP-Delegator-Script:
After Unzipping, please ensure the following first:
- move the ServerLib.asp File in the Zips Root-Folder into your local: C:\inetpub\wwwroot\asp\ Folder
This script-file is pretty small, and contains the following:
Code:
<% @EnableSessionState=False %>
<%
On Error Resume Next
Server.CreateObject("ServerLib.cASP").HandleRequest Application, Server, Request, Response
If Err Then Response.Write "Error: " & Err.Description
%>
As for an explanation of the above...:
- the first line (EnableSessionState=False) will suppress unnecessary Session-Handling-efforts on the side of the IIS (and also suppresses "client-side cookie-writing").
- the following Block is just an "InPlace-Error-handled Instancing-Call into a COM-Dll
...using the ProgID "ServerLib.cASP" (which is exactly the Naming-Scheme of the AX-Dll and -Class that is contained in our VB6-Project).
...and the HandleRequest MethodCall just passes 4 IIS-Context-Objects along (Application, Server, Request, Response )
Note, that this ASP-Script is the only thing you'd ever have to write "Script-Code-Wise" to make all the stuff which now follows, work -
we will never (in the context of this series) come into contact with ASP-Scripting again (all the rest of the serverside-handler-code will be VB6-Code).
VB6-Project-Startup and -Description:
Now (after placing the little ASP-Delegator-Script in the IIS-asp-Folder), one can proceed by starting the VB6-ProjectGroup:
- by DoubleClicking the _ASPTest.vbg File from within the Demos Root-Folder...
The upstarted Project-Group contains (in sum) only about 30 lines of code - and the Project-Tree of that Group should look like that:
- the RPCTest ProjectTree-entry above (our StdExe-Client) is the "Default-Project" the Group uses when starting up
- and the ServerLib ProjectTree-entry (our AX-Dll-Profject) contains the Code which runs on the serverside
Note, that you do *not* have to compile neither the AX-Dll-Project, nor the StdExe-Project -
the whole thing (when the IIS was set-up properly beforehand) should work "out-of-the-box"...
Testing the RoundTrip:
To test the RPC-Roundtrip, please enter the cASP Class-Module-Code and place a BreakPoint in its "HandleRequest"-Method:
Code:
Option Explicit
Public Sub HandleRequest(Application As Object, Server As Object, Request As Object, Response As Object)
Response.Write "Hello World" 'place a BreakPoint here, to see the RoundTrip-Debugging in action
End Sub
Now run the ProjectGroup - and click the Form (which triggers the RPC) -
if your VB6-IDE now stops the execution within the HandleRequest-method, we've successfully completed Step 1 in this little tutorial...
(just let it run further with <F5> - or use the <F8> to see, where you come-out, when the HandleRequest-Method is exited).
Olaf
Last edited by Schmidt; Oct 1st, 2018 at 12:56 PM.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by Peekay
I cannot download and/or open the RPCtest_simple zip file. Can you just check please.
I've just done that - and it works without problems here... (when the VBForums-DL-Link is clicked from within an "up-to-date Mozilla-FireFox").
Not sure, why you cannot download it (and it seems that it was downloaded by other Users already more than 10 times, quite sure someone would have complained, if there was something not working).
What Browser are you using (perhaps switch to a different one - and try again)?
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by Peekay
I have downloaded the program group and mine works. Its incredible!
Ah, good to know...
Then let's proceed with Part2 of the Code-Demos (now addressing Parameter- and ReturnValue-Transport in the RPCs).
Here's the Demo-Code: RPCTest_WithParams.zip
It will behave in the same way as the first, simpler Demo - also requiring no compilation - just the Startup of the _AspTest.vbg
(but please make sure, that a potentially still running IDE-instance of a previous AspTest-ProjectGroups is closed, before you start the new ProjectGroup).
Parameter- and ReturnValue-Transport in RPCs:
In Browser-Apps (which use JavaScript in conjunction with "Ajax" to perform the same kind of http-RPCs),
the Parameter- and ReturnValues are transported via "serialized JavaScript-ObjectContainers" (JSON).
Now, in VB6 we could use JSON-serialization via appropriate support-classes as well -
but since the "main-work" of the whole Remote-Layer will later be focused on "interaction with a serverside DB in a Rich-VB6-Client-App",
we can as well use a Container-Type, which supports these DB-related tasks already, but "normal, non-DB-related tasks" as well -
so, what I'm talking about is obviously a (disconnected) ADO-Recordset.
Since an ADO-Rs can:
- also be created "standalone" (without any DB-relations)
- can contain multiple Params in different DataTypes (in several, appropriately typed Fields)
- and already supports a binary-serialization-format with low size-overhead (over its Rs.Save-Method)
it is an ideal candidate for our task of "Parameter- and ReturnValue-transport"...
So this second Demo now comes:
- with a *.bas-Module that contains ADO-Rs-serialization-HelperRoutines
- and a slightly changed DoRPC-method (in cRPC) - its Function-signature now looking this way:
Code:
Public Function DoRPC(ProcName As String, ParamArray P()) As Recordset
So our DoRPC-routine now expects the User to pass on:
- a serverside ProcedureName
- followed by a ParameterList of arbitrary length (any of the simpler Variant-Types are supported, including ByteArrays).
Here's what this second Demo now contains in the Form_Click-EventHandler:
Code:
Private Sub Form_Click()
Dim RsResult As ADODB.Recordset
Set RsResult = RPC.DoRPC("GetServerTime") 'Demo-Call with no Parameters
' Set RsResult = RPC.DoRPC("ReflectString", "ABC") 'Demo-Call with 1 Parameter
' Set RsResult = RPC.DoRPC("AddNumbers", 1.5, 2) 'Demo-Call with 2 Parameters
' Set RsResult = RPC.DoRPC("AddNumbersReflectAndTime", 1.5, 2, "ABC") 'get multiple Results in one single RPC-RoundTrip
' Set RsResult = RPC.DoRPC("DivideNumbers", 1, 0) '<- we pass 0 as the second arg, to show how serverside errors are transported
VisualizeRs RsResult
End Sub
So, the usage should be quite obvious - and I recommend to try out each of the example-calls
(commenting lines in- and out appropriately), then stepping through them, to get a better feel for the whole thing).
As one can see, the ReturnValue(s) will always be transported in an ADO-Rs (also in case of an encountered Error along the way) -
so an MSHFlexGrid was choosen to visualize these returned Results (but one can of course also access the return-values in a "non-visual-way", direclty from the RsResult).
As said, play around with it for some time (including implementing your own serverside routines in the cHandler-Class, addressing those as well from the clientside Form-Project).
In the next Demo we will "get serious" (based on these Rs-based Transports) - and address a serverside DB...
Olaf
Last edited by Schmidt; Oct 1st, 2018 at 01:00 PM.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by DaveDavis
What is the windows configurations for IIS? Refer to the screenshot.
Checking the "IIS Management-Concole" should be enough...
On Win10 you will then find the InetMgr-App when you go over your:
<Control-Panel>... and there doubleclick on<Management>... one of the Icons within the Management-Window should be associated with the IIS-Mgr.
(the above terms were translated from a german OS, where they are named: <System-Steuerung><Verwaltung>...).
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
I'm afraid I had to remove the link from the first post, as it contained compiled code. While we don't expect that there is anything harmful in it, and it seemed like a pretty useful addition, the policy is pretty clear: We can't say anything about compiled code, including whether or not it is what it says it is, so it is not allowed in this forum.
As to the second link. That doesn't even appear to be working, so I left it, because it may or may not even exist.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
I'm afraid I had to remove the link from the first post, as it contained compiled code. While we don't expect that there is anything harmful in it, and it seemed like a pretty useful addition, the policy is pretty clear: We can't say anything about compiled code, including whether or not it is what it says it is, so it is not allowed in this forum.
As to the second link. That doesn't even appear to be working, so I left it, because it may or may not even exist.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by wqweto
The .tlb can be a target for Project Compatibility only as in attached samples.
Yep - and nobody will need to change these default-settings, ever ...
(in the given context of using the Server-Dll in conjunction with the IIS)...
Originally Posted by wqweto
For Binary Compatibility one can expect to get A compatible ActiveX component must be a Visual Basic executable error -- bummer!
Switching to true BinComp-mode is (as said) not necessary for the ServerLib.dll Project,
because the IIS will always use it in LateBound-mode.
Working in Project-Compatibility-Mode puts less restraints on the Code(r) in the development-phase -
and since it is used LateBound later - one can always compile a new Dll-Binary without worries, because
also in Project-Compatibility.-Mode, the ClsID of the "Entry-Class" cASP will still remain constant and the same as it currently is:
{FD324400-2660-4DE3-B1A8-70A7034F59FD}
Later - on the IIS - which often does not allow access to the registry (nor "a shelling of regsvr32.exe") on the production Host-Machine,
one can use it regfree via a little (side-by-side-placed) manifest, named ServerLib.manifest which only needs the following content:
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Agree. I was just lamenting BinComp inability to target the .tlb only as I have no idea why the .dll is required in this case. VBForums' policy of no executables in attachments aggravates the matter for samples in threads like current even worse.
Anyway, confirming that CLSIDs remain stable in PrjComp mode is news for me. I'm using PrjComp myself extensively as with BinComp IDE's auto-completion becomes extremely slow on some large projects.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by PhuongNam
this topic is great ... this post too can you please continue ???
Writing a Demo DB for the server ???
Yeah, sorry... the "RPC-mechanism" as introduced here, was later continued in several (quite long and detailed) other threads -
in the normal VB-Forum (where ADO-based DB-access - and the transfer of selected Rs was explained): https://www.vbforums.com/showthread....nection-string
(from posting #23 onwards, post#58 containing code for a modADODB.bas, which can be added into the ServerLib-Dll project)
Before diving into these threads though, one would be well-advised, to make the code in this thread work first, fully understanding what it does -
(including setting your own break-points in the serverside Dll-Class-Code of the ProjectGroup which was used here).
HTH
Olaf
Last edited by Schmidt; Nov 2nd, 2020 at 03:48 AM.
Reason: Fixed ThreadNr-reference
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by Schmidt
Yeah, sorry... the "RPC-mechanism" as introduced here, was later continued in several (quite long and detailed) other threads -
in the normal VB-Forum (where ADO-based DB-access - and the transfer of selected Rs was explained): https://www.vbforums.com/showthread....nection-string
(from posting #23 onwards, post#52 containing code for a modADODB.bas, which can be added into the ServerLib-Dll project)
Before diving into these threads though, one would be well-advised, to make the code in this thread work first, fully understanding what it does -
(including setting your own break-points in the serverside Dll-Class-Code of the ProjectGroup which was used here).
HTH
Olaf
Thank you for agreeing with your suggestion
1 / I have configured iis.msc as instructed in lesson 1, finished
2 / modADODB.bas is in song # 58, not song # 52
3 / I read and re-read the 2 links you gave, basically ADOBD reads and writes data to the DB, then I'm fine ... and "serialization" (to and from ByteArrays) as you described, I I have never used it before ... if you instruct me, I will learn quickly because basically ADOBD I use ok
4/2 Link you only see many times if there is 1 Demo, I will understand that this road does not have a Demo, but only 2 people exchange with each other so I am a bit difficult to figure out how.
We hope you guide me to approach like this topic
Last edited by PhuongNam; Nov 2nd, 2020 at 12:43 AM.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by PhuongNam
I will understand that this road does not have a Demo, but only 2 people exchange with each other so I am a bit difficult to figure out how.
I think, the amount of Demos (even in this very CodeBank-thread here) should be enough,
to figure things out on your own.
For example, I've posted an RPC_TestWithParams.zip in post #7 in this thread here.
Please make this work for you fully first:
- by starting the Project-Group
- and then by setting a breakpoint in cHandler.cls ... GetServerTime()-method (of the ServerLib-Project which is part of the VB6-Group)
If you have managed that, you are already set-up for "everything else" (including "talking to real, serverside DBs via ADO).
Just tell me, that you indeed end up in a breakpoint in that project -
and let's take "things from there".
I'm hesitant to write "special DB-Demos" for this approach, because it is already generic enough
(using ADO-Rs as transport-vehicles for any kind of Incoming and Outgoing Parameters already).
You have to fully understand, how to work with RsIn and RsOut:
- using them for "normal Parameter-transport" ...
From there, it is not that large a step, to write your own Sub-Routines in cHandler.cls,
which for example could look as simple like (after hanging the modADOD-module into the ServerLib-Project):
Code:
Public Sub GetServerRs()
If Cnn Is Nothing Then Set Cnn = modADODB.OpenCnn(...) 'set a class-private Cnn-Variable, if necessary
Dim SQL As String: SQL = RsIn(1).Value
Set RsOut = modADODB.GetRs(Cnn, SQL)
End Sub
... to retrieve an ADO-Rs from a priorily opened Cnn
Olaf
Last edited by Schmidt; Nov 2nd, 2020 at 06:09 AM.
Re: VB6 IIS-Configuration for RoundTrip-Debugging of http-RPCs
Originally Posted by Schmidt
I think, the amount of Demos (even in this very CodeBank-thread here) should be enough,
to figure things out on your own.
For example, I've posted an RPC_TestWithParams.zip in post #7 in this thread here.
Please make this work for you fully first:
- by starting the Project-Group
- and then by setting a breakpoint in cHandler.cls ... GetServerTime()-method (of the ServerLib-Project which is part of the VB6-Group)
If you have managed that, you are already set-up for "everything else" (including "talking to real, serverside DBs via ADO).
Just tell me, that you indeed end up in a breakpoint in that project -
and let's take "things from there".
I'm hesitant to write "special DB-Demos" for this approach, because it is already generic enough
(using ADO-Rs as transport-vehicles for any kind of Incoming and Outgoing Parameters already).
You have to fully understand, how to work with RsIn and RsOut:
- using them for "normal Parameter-transport" ...
From there, it is not that large a step, to write your own Sub-Routines in cHandler.cls,
which for example could look as simple like (after hanging the modADOD-module into the ServerLib-Project):
Code:
Public Sub GetServerRs()
If Cnn Is Nothing Then Set Cnn = modADODB.OpenCnn(...) 'set a class-private Cnn-Variable, if necessary
Dim SQL As String: SQL = RsIn(1).Value
Set RsOut = modADODB.GetRs(Cnn, SQL)
End Sub
... to retrieve an ADO-Rs from a priorily opened Cnn
Olaf
Thank you very much ... I still have not figured out how to use the code in the Demos that you put up here ... if I keep asking stupid questions over and over, it just makes you angry. only ... so for the past few days I still reread your article and think
You can show me only 2 most specific examples that I can imagine and use
For example: C: \ Data \ Database.mdb in File has the table named: Persons
1 / So how can I use ADODB to get the data with the table named: Persons?!
2 / How did I get the data of another Data.mdb and save it to C: \ Data \ Database.mdb?!
I hope you show me two detailed sections that are how to get data and save data to Database.mdb, so I can visualize and apply the code to share it right away