Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sending XML data between two VB Applications

Posted on 2004-10-01
4
186 Views
Last Modified: 2011-08-18
Hi everyone.

I have a problem, and there seem to be a large variety of solutions :) Better than having no solutions i guess, but what i am after is suggestions and reasons of the best method to perform what i need (and possibly some sort of link to a tutorial or key code example).

Background:

I have an applicaiton (lets call it APP1) that sits listening on a socket. It receives XML 'actions' via the web.
I have a second application (APP2) that knows how to perform XML actions and return an XML response.
APP1 gets the action from the web, gives it to APP2, APP2 does its thing and returns it back to APP1 which then sends the XML response back down the socket.


What I need is some way to send the XML from app1 to the app2 (and back again in reply) which will:
a) not require a socket to be opened (other than the one already open by APP1 of course)
b) allow APP1 to completly stop APP2 so that it is no longer in memory (this way the exe can be overwritten) - will this be a problem if APP2 is an activeX exe?
c) allow large XML docs to be sent from APP1 to APP2 (possibly up to 1MB - not sure if this will be a problem with DDE or COPY_DATA)

Just to clarify, I want APP2 to be seperate from APP1 because I want to be able to remotely upgrade the collective application. The idea is to have APP1 as thin in funcitonality as possible, reducing its need to be upgraded. APP2 (or any dlls/files/etc that it uses) can be upgraded and APP1 can still send a response regarding the success/failure of the upgrade. When APP1 is upgraded (it needs the exe to be replaced) the socket will be closed and a response will not  be possible, so id like this to happen as little as is possible.

I have researched a bit on:
* APP2 as a ActiveX Exe - I am unsure if I will be able to kill the ActiveX exe, replace the actual exe file and then restart it again whilst APP1 is running
* DDE - My primary concern is that it seems a little outdated, also im unsure about send limits (maybe need to transfer a uuEncoded binary which could be pretty big) and do i need a text box or somehting? I would rather not rely on GUI controls as this app is intended to run in the background.
* Using COPY_DATA - unsure on limitations this may have.

I know that there are a variety of other methods, which im open to, but i prefer that the solution is primarily in VB and that it is not going to be a huge task to implement as the schedule is very tight :( .... i guess they always are.

Dont worry about going into too much detail with the example if you provide one - just enough to get me started, im more concerned about the apporach, i can always offer more points on another quesiton if I have any issues with the code itself.

Thanks soo much, sorry for the long post, it's in an effort to reduce questions and save time for everyone.


0
Comment
Question by:gimmeadrink
  • 2
4 Comments
 
LVL 6

Expert Comment

by:SCDMETA
ID: 12206232
Other Suggestion 1: Directory Change Notification
The following link shows how you can create applications that get notification when a directory changes.
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=41816&lngWId=1

My thought process is App1 writes XMLto a directory that App2 is monitoring.  App2 is notified of the new file(s).  
App2 reads the new files, processes them, and then writes its response to the directory that App1 is monitoring.
App1 is notified of the new file(s). App1 reads the data and send it on the wire.

Other Suggestion 2: Named Pipes
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q177696
App1 creates a named pipe.  App2 knows the pipes name so it opens it.  App1 writes it's data into one end of the pipe, App2 receives the data.  App2 writes its response into the pipe.  App1 receives the data.  

Other Suggestion 3:
Memory Mapped Files
http://www.mvps.org/vb/hardcore/html/sharedmemorythroughmemory-mappedfiles.htm
App1 creates a memory mapped files. App2 copies the data out of it.  Process is reversed to send data back.
0
 
LVL 2

Author Comment

by:gimmeadrink
ID: 12206342
Thanks for the suggestions....

I'm going to wait until i have a few more replies before i investiage anything in case something sticks out as a good option straight away.

NOTE: the methods i suggested are not necessarily invalid, i have just listed my concerns, i would be more than happy for some one who understands them better than I to point out if my concerns are wrong/invalid/whatever

thanks
0
 
LVL 26

Accepted Solution

by:
Rejojohny earned 500 total points
ID: 12211421
>>a) not require a socket to be opened (other than the one already open by APP1 of course)
* APP2 as a ActiveX Exe - I am unsure if I will be able to kill the ActiveX exe, replace the actual exe file and then restart it again whilst APP1 is running
Using a activeX exe is good idea .. u could expose a method within this COM to stop itself .. to restart after copying the new version ... APP1 could instantiate APP2 using "getobject" instead of the "New" clause .. i am not sure whether this will work for activex exe .. but works for dlls instatiated within the same process .. basically "getobject" looks for existing instances of APP2 and if not found will return "nothing" .. then u can create an instance of "APP2" or else use the exiting object returned.

b) allow APP1 to completly stop APP2 so that it is no longer in memory (this way the exe can be overwritten) - will this be a problem if APP2 is an activeX exe?
as mentioned above

c) allow large XML docs to be sent from APP1 to APP2 (possibly up to 1MB - not sure if this will be a problem with DDE or COPY_DATA)
u could again expose methods within ur activex exe to accept xml strings .. or probably save the xml into a shared directory and pass on the path to ur APP2's method which could in-turn open the file and do the reqd. operation ..
0
 
LVL 2

Author Comment

by:gimmeadrink
ID: 12211583
Hiya,

ActiveX does work

I originally had problems upgrading APP2 without having to recompile APP1, but now im using CreateObject and its all looking sweet

Thanks for your advice.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

840 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