?
Solved

Exposing an Object in VB6 that can be used in standard ASP script

Posted on 2005-04-10
13
Medium Priority
?
301 Views
Last Modified: 2010-05-02
I need to be able to pass a text string from my ASP script to a visual basic 6 exe. My VB6 project has a simple form with a text box on it. I have added a class to expose the Text Property and have added 1 method to write this property to the text box. The VB6 application is called AmegaWeb and the class is called Transfer. When I try to instantiate the object in my ASP script, I get the following error;

Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid class string
/SendSVR.asp, line 37

The code in the script is as follows:

37   Set xfer = Server.CreateObject("AmegaWeb.Transfer")
38   xfer.Txt = strSEND
39   xfer.Exec
40   Response.Write "The result of this call was: " & Cstr(xfer.Result)
41  set xfer = nothing

I tried registering the AmegaWeb.exe to no avail. If this method is not possible, I need any solution available to be able to transfer a string of data from an ASP script to a visual basic 6 application. I tried using sockets and could not get that to work either.

Any help would be appreciated.

Thank You.
0
Comment
Question by:RonCangro
  • 5
  • 4
  • 3
12 Comments
 
LVL 8

Expert Comment

by:anthonywjones66
ID: 13746874
The problem is that a VB6 Exe application with a form needs an interactive session to start in.  Does this exe really need to be an EXE.  Can you not use an ActiveX dll instead?



Anthony.
0
 

Author Comment

by:RonCangro
ID: 13746989
Yes, the VB6 application does need to be an exe. What exactly do you mean 'needs an interactive session to start in'? Eventually, I need to get the string data back to the exe application, but I am not opposed to going through another step if it would be easier. What I mean, is possibly creating a DLL that communicates with the ASP script and the VB6 application. But unless another method is used to communicate back to the VB6 app, I am in the same boat.

Ron
0
 
LVL 8

Expert Comment

by:anthonywjones66
ID: 13747885
Where is the EXE program running?  On whose desktop does the form appear?

The ASP web site runs as a service, it isn't associated with any desktop.  If it were to launch an application that requires a user interface bad things can happen.

I'm not sure what to suggest really.  You can go for complex solutions such as:-

If the application MUST run with a UI then you could have the EXE running on the logged on console (or Remote Deskop Session) and have it register an object in the Running Object Table.  A separate utillity dll could then be used by ASP to retrieve the object with which you can communicate.  

or

Since you have access to the EXEs code you might consider breaking the Exe down and move the UI into an EXE and the logic into a DLL.  The DLL could be installed in COM+ and shared by both ASP and the UI.  This is the 'correct' solution from an architectural point of view.

On the other you can go for quick and dirty solutions such as:-

Have the EXE monitor a folder and have ASP create files in the folder.  (or message through a DB table.).

or

As it seems you may have already tried using some kind of sockets solution.

It really depends on how much time and effort you want to put in to the solution.

Also does the ASP need to wait for successful completion or returning data from the EXE?

Anthony.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RonCangro
ID: 13748015
Currently I have the EXE running on the same computer as the Web Server. The GUI appears on my login. The ASP does not have to launch the EXE, it will always be running. The EXE is communicating with other programs via a sockets interface.

Method #1:  How would I have the EXE 'register an object in the Running Object Table'? I am not familiar with this. How would the separate utility DLL communicate to the EXE?

Method #2: I assume in this method, I create a DLL that has the object that will do the transfer from the ASP to EXE. However, I think there is a drawback; I require the EXE to be notified asyncronously when a button is pressed from the ASP. Could I accomplish that by continously polling the DLL to see if it has data from the ASP? Also, I am not sure how to install the DLL in COM+ (is that just registering it via regsvr32?).

Method #3: If you could give me some insight on the sockets solution, I may be able to use it. Every time I try to connect to the socket on the EXE, the status of the socket remains 'connecting' it never gets to 'connected'. if I put it into a loop waiting for the 'connected' status it gets hung up.

Method #4: Having the EXE monitor a folder is a last resort. I just think there has to be a better solution. Maybe an XML message via SOAP or something like that. I just don't have the experience to know.

Maybe you could suggest some sample code that I could try out. By the way, the ASP doesn not have to wait for completion and is not expecting any data from the EXE. This is a project that needs completion quickly so I am willing to put in as much effort as is needed.
0
 
LVL 8

Accepted Solution

by:
anthonywjones66 earned 200 total points
ID: 13748060
Method #1:  Let's shelve that one because it is quite heavy.
Method #2:  I was proposing something far more drastic. The break of the EXE into components such that the ASP not longer had to communicate with a UI bearing EXE but with COM+ app that did all the real work.

Method #3:  Since you already have this in place in the EXE this would seem to be the most logical solution.  Can you show some code you were using?

Method #4:  Since you only need asynchronous access this is not such a bad option and is more robust than any of the others.   You don't need to burden yourself with SOAP etc.  just a simple XML format containing what you need will do.

Anthony.
0
 

Author Comment

by:RonCangro
ID: 13748283
The following is the ASP code I was using for Method #3 Socket Connection:

' Set up the Socket
set wsock = server.createobject("MSWinsock.Winsock")
wsock.remoteport=1111
wsock.remotehost=strPath   ' Retrieved from an INI file
wsock.close
wsock.connect
' Also tried putting a loop here to wait for sckConnected (7)
if wsock.state=sckConnected then
  'Send Data to EXE
  SvrMsg = "00147,1=Indoor Temp N4,1.5"
  wsock.SendData SvrMsg
else
  ' Can't Connect
  Response.Write "Socket State: " & Cstr(wsock.state)
end if
wsock.close

On the VB side I added a socket control and initialized:
wsckWeb.LocalPort = 1111
wsckWeb.Listen
' Process data in DataArrival() Event

Could you suggest code for Method #4 XML message?
Would the less Drastic Method #2 (Just separate Transfer Object into DLL) work?

Ron
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13748445
You said the socket hands on trying to connect. My  question is what are you passing in the variable strPath?
0
 
LVL 8

Expert Comment

by:anthonywjones66
ID: 13748560
Wsock.remotehost = '127.0.0.1'

Ought to work on the same server but this is followed by:-

wsock.close ???

also you do handle the connect request and call accept in the EXE don't you?

Anthony.
0
 
LVL 9

Assisted Solution

by:sk33v3
sk33v3 earned 200 total points
ID: 13748575
Remember don't forget on your loop to take into account any errors that may occur. So try the loop below.

'' Set up the Socket
set wsock = server.createobject("MSWinsock.Winsock")
wsock.remoteport=1111
wsock.remotehost=strPath   ' Retrieved from an INI file
wsock.close
wsock.connect
' Also tried putting a loop here to wait for sckConnected (7)
do until wsock.state=7 or wsock.state=9
  '' we are waiting for the socket to connect(7) or Error out(9)
loop
  if wsock.state=sckConnected then
    'Send Data to EXE
    SvrMsg = "00147,1=Indoor Temp N4,1.5"
    wsock.SendData SvrMsg
  else
    ' Can't Connect
    Response.Write "Socket State: " & Cstr(wsock.state)
  end if

wsock.close

On the VB side I added a socket control and initialized:
wsckWeb.LocalPort = 1111
wsckWeb.Listen
' Process data in DataArrival() Event
0
 

Author Comment

by:RonCangro
ID: 13748822
I added the check for wsock.state=9 in my loop, and it still hangs. When I remove the loop I see a socket State: 6 from the response.write statement. It doesn't seem to be getting past the 'Connecting' state.

In the ConnectionRequest Event on the EXE I have the following Code:
    If wsckWeb.State <> sckClosed Then  wsckWeb.Close
    ' Accept the request with the requestID  parameter.
    wsckWeb.Accept requestID

Is there any other code I need in the EXE to Accept the Connection?
0
 
LVL 9

Expert Comment

by:sk33v3
ID: 13749003
Well if the remote host doesn't resolve it can take a while for it to return unresolvable.
0
 

Author Comment

by:RonCangro
ID: 13805879
It has been a week and I have not got the answer I have been looking for. I am still unable to communicate from my ASP script to my Visual Basic Application. I have not been able to get the sockets interface to work, nor has there been enough information to get any other method to work. I am going to ask that this question be deleted and each person who responded be given 50 points.

Thank you, but I am no closer at solving this problem than I was when I first asked it.

Ron
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question