Call procedure from external program

Hi all,

We investigating ways to call a procedure from an external program, but so far have no success. Specifically, we have a .NET application that needs to initiate a procedure file in an existing OpenEdge session.

We all know that OpenEdge can call COM-enabled functions in external programs via ActiveX (eg MS Excel), and I though perhaps it would be possible to call back the other way. So far I can't find anything to support this though.

Another idea was to use the Open Client.. until we realised it requires an AppServer.

I had a look at Re-parenting Progress' main window which looks helpful, but I don't quite understand it..

Any ideas?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Success

Just thought I'd share that I've gotten this working.
Took a little fiddling in .NET to make sure I had my bytes in the right order, but it's not too complicated.

For anyone considering the code on slide 50 (read-response event) of sti_socket_programming.ppt, make sure to add a check of hSocket:CONNECTED(). I found that the System.Net.Sockets.Socket.Close() method will fire the read handler, so a call to hSocket:READ() will cause an error.

I'd be happy to share the code on request.


jurjen's picture

re: Success

Good! The thing I am curious about is: how do both programs agree which port number to use?


re: Success

Currently I have hard-coded the port number, but will probably make it a user-customisable value, which they will have to maintain in both programs.
Another thought I had was that the .NET application will sometimes be spawning the OpenEdge application, so the port number could be passed as a command-line parameter. But I can't rely on this, so I won't be doing that.


tamhas's picture

The official right answer,

The official right answer, as you have already discovered, is AppServer. Sockets or pipes are another option. You might also consider web services. Of course, you could also go the Sonic route, but I am presuming that you are balking on AppServer based on price so you won't like that idea either. :)


jurjen's picture

Re: call procedure from external program

OpenEdge cannot be an ActiveX server so you cannot connect to it from an ActiveX client. Perhaps you could do it the other way around: let the .NET program be the ActiveX server, connect to it from OpenEdge, call an event method from within .NET which is handled by OpenEdge.

Better and much easier: sockets. Let OpenEdge start a socket listener, somehow publish the port number, and now the .NET application can talk to that port. That's how the Eclipse / OpenEdge integration works. Challenge is to make it hack-proof, because a socket can be talked to by anyone in the universe, theoretically.


Thanks for your responses

Thanks for your responses guys. They've been very helpful!

Sockets looks like the way to go - nice and light and simple (no need for AppServer or Sonic).
I've found the following presentation to be a good start for someone like me who's never used sockets before: www.psdn.com/library/servlet/KbServlet/download/499-102-571/sti_socket_p...


tamhas's picture

Take PSDN sample code

Take PSDN sample code relating to sockets with a grain of salt ... or perhaps several shakers full. It mostly illustrates a few principles and doesn't present good production ready models for how to work with sockets. Greg Higgins is supposed to be working on a book, but until then, ask lots of questions and do lots of experiments.


jurjen's picture

re: Take PSDN sample code

I have seen such answers before to various questions and it not only worries me, it also annoys the hell out of me. It worries me because you and Greg and maybe more Masters have found the secret truth, but me and some PSC book writers don't, and it annnoys me because apparently the truth is not something that can be shared (in the format of a working .p) but needs to be discovered by my novice self with "lots of experiments".
I can't believe that a socket is so dramatically arcane that you'd need a BOOK to publish a production-ready sample and that we have to wait for Greg Higgins.