0

We have a program (A.exe) with GUI and a toolbar who does NLP stuff with some text. In that toolbar we have function A which transform the text by adding some xml tags. Someone here (the boss) would like that I create a Web Service calling function A. It told me about Dynamic Data Exchange (he used it few years ago), I saw something like SendMessage.

The Web Service will be used by someone over the Internet : sending a text and getting the result as xml. The GUI program could not be started when someone calls the WS because it is too slow, so someone sugggests to launch this A.exe once for all and the WS will ask this A.exe by sending a DDE call. I don't know how A.exe will react in case of concurrent calls.

The Web Service will:

  1. save the text file in a directory
  2. call the A.exe
  3. the A.exe will compute the text file and create the xml file
  4. the WS will loop until the xml file exist
  5. the WS will get the xml and send it as stream to the original caller

I would like to note that:

  1. DDE is old and seems to need a DDE server capable program.
  2. SendMessage is a little bit obscur as I am a Java developer.
  3. I did not try named or anonymous pipes to make that call as suggested.

Thank you.

PS: It is an heresy to build a WS calling a server-side program with UI, isn't?

Community
  • 1
  • 1
enguerran
  • 3,193
  • 3
  • 26
  • 42
  • Update your question with more details about how the application works and what it is trying to do. What is process A (UI) and process B? What does process B expect process A to do? Does process A talk back with process B? – Jordan Parmer Apr 04 '12 at 12:45
  • I add some details. Are they understandable? – enguerran Apr 04 '12 at 13:04

1 Answers1

1

The answer to this question really depends on what you are trying to accomplish. Does your function alter data coming from an external data source such as a database or are you invoking a function within an application?

I would start with the following questions.

1) What does the function of the button do? Can it's functionality be moved into a service and shared between multiple applications?

2) Can you put the functionality inside a DLL and share between two applications?

3) Do the two apps really need to communicate with one another?

If the two processes MUST communicate with one another and you merely want application A to behave in response to a message from application B, consider using named pipes for TCP/IP communication. This is simple enough in .NET and provides quick communication between processes.

UPDATE: Here is a link with info on using named pipes: http://msdn.microsoft.com/en-us/library/bb546085.aspx.

UPDATE 2: This is an update after you updated your question. Do you have access to A.exe's source code? If you do, you have two options: 1) move that logic into your service or 2) modify A.exe to accept command-line parameters so that your service can invoke the process and get back results. If you don't have source code and you can't invoke A.exe from the command-line, then there isn't much you can do other than write the process yourself in a form your web service can call.

P.S. You don't have to worry about concurrent calls because each server request will execute a separate process.

Jordan Parmer
  • 36,042
  • 30
  • 97
  • 119
  • To answer your pertinent questions: 1) No because my boss don't want to. 2) No because my boss don't want to. 3) Yes because my boss sell it as it. => in fact the UI program loads a text and returns a xml. The WS will take the stream and return a stream... But "Nul n'est plus sourd que celui qui ne veut entendre !" – enguerran Apr 04 '12 at 12:37
  • Then used named pipes or simple TCP/IP. See my updated wording in the post. – Jordan Parmer Apr 04 '12 at 12:38
  • I added a link with a simple example of using named pipes. These provide quick/simple inter-process communication. If you need further assistance, consider updating your question with more details about the specific problem you are trying to solve. – Jordan Parmer Apr 04 '12 at 12:41
  • Thanks a lot. I did not ask myself about concurrent calls of this UI program... I guess it will crash as soon as used. – enguerran Apr 04 '12 at 12:42
  • 1) we have source code but the boss don't want to move the logic into my service 2) I can propose such a solution. I gratefully thank you very much! (A.exe is an old UI program containing a lot of LoC and the author, aka the Boss, ...well!) – enguerran Apr 04 '12 at 13:23
  • If that is the situation, you could propose this. Move the code that does the task you want into a separate DLL within the same UI solution. Then, re-wire the UI application to use the DLL. You can then use that DLL in your service. That way the code base stays with the original UI application, but you can now share the binary with the service. Just an idea that he might consider. – Jordan Parmer Apr 04 '12 at 17:25
  • After a week, the war seems to be over. He accepts to add code to take command arguments. But he said : "it is back to the past to use command-lines." ;) ahhh, work is amazing ! – enguerran Apr 06 '12 at 10:52