Solved

Sending XML data between two VB Applications

Posted on 2004-10-01
4
182 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now