Making delphi communicate with a c# service

Hi, I have developed over the years a software using Delphi.   I need to add a function which can only be programmed using c#, this function would basically receive a command, process some DATA and return a result.

My idea was to build a c# service which would be always loaded on a server (or the workstation itself) and somehow making request to this service from my delphi application.

I know a little about REST, I'm not sure if this could be a possible solution, what I like is that I send a JSON and get the answer via a IP adress, that could be good but I'm not sure how to create a REST server and if I can use c# code to read the JSON, get the info and send back the result to my delphi app.

I could also write in a SQL database when I wan't the service to return DATA but since the c# part is going to be called a lot, I fear that this could make too much traffic on the network.

In short, I need help to find a solution to make a request to a running c# software from delphi with some parameters and read a result.
Buropro-CitationAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Geert GOracle dbaCommented:
only be programmed in c# ?
i'll try not go dig into those details as some messed up stuff may come up ... grin

there is extensive page on Delphi and rest here :
http://docwiki.embarcadero.com/RADStudio/Berlin/en/REST_Client_Library
0
 
Buropro-CitationAuthor Commented:
Yes indeed, long story as to why I have no choice but to use c#.    I have looked at the web page, it seems to focus on how to use REST and what it is, this is nice but I'm already familiar with using REST from my delphi app, what I'm looking for is how to actually build my own REST service using c# and to know if I can use c# code to process the information needed before returning it.
0
 
käµfm³d 👽Commented:
Have you looked at OWIN self-hosting via Katana, yet? You could run a console application or Windows service on the host machine if you'd rather not use full-fledged IIS for hosting.
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Buropro-CitationAuthor Commented:
Can this be installed on visual studio 2010?
0
 
käµfm³d 👽Commented:
Uncertain. I believe so, since it's done via NuGet; however, there might be dependencies on a the newer versions of the Framework (4.5, I believe), and I don't recall how high 2010 supports.
0
 
Buropro-CitationAuthor Commented:
2010 seems to go only to 4.0, looks like I would have to buy a new visual studio to test the OWIN solutions, which looks promising at first glance.
0
 
Buropro-CitationAuthor Commented:
If someone has a solution beside REST, I'm open to all suggestions, so far this seems that best path (using OWIN).   If there's a way to access a service loaded on the workstation via Windows handle or something that would be great too I guess.
0
 
lopemCommented:
I'm going just to suggest an idea that I am not sure if its a working one: some time ago I wanted to get data from a chess engine using a delphi program. For a long time I had no solution for the problem until I found a component that reads the data of a chess engine provided by a communication chess engine protocol. But in fact, the chess engine send thru the standard output the data (chess variations and move realized), and I dont have to know if this is a c#, c++ or c program. I dont really care how the external program ia sending the data. The component (for delphi) can be downloaded from the russian site: http://kladovka.net.ru/index.cgi?pid=list&rid=222).

Maybe this is a way to solve your problem.
Best wishes
Manuel

Ps. I can send part of my code if needed to understand how to use the omponent.
0
 
käµfm³d 👽Commented:
...looks like I would have to buy a new visual studio...
Depends on your needs. You could always use the Community Edition to do the proof-of-concept, if your shop is small enough to meet the requirements.
0
 
Sinisa VukCommented:
One way could be using SOAP .... but on the other hand - is it easy to implement simple tcpip client/server - with custom packets (could be xml,json,...). On Delphi side can be Indy and on C# side - TcpListener or similar... I do similar job but in opposite way (c# -> Delphi)
0
 
Buropro-CitationAuthor Commented:
Problem with the IP listener, the communication seems to be one way from what I can see, I can't send data and read a response at the same time like SOAP or REST enable me to do, am I correct in assuming this?
0
 
Sinisa VukCommented:
No. Even soap and rest cannot "communicate" at the "same" time. They need to send request first, then receive a response. Tcpip client/server is lower technology behind soap and rest.  So, your ip listener is able to communicate same way....
0
 
Buropro-CitationAuthor Commented:
With REST, I would indeed have to wait for the reply when using idhttp.post.   Would I be able to do the same with the iplistener, which is to send a request and get the answer in one command?
0
 
Sinisa VukCommented:
Yes, you can do the same... When connected ... server can send data through same channel (connection) to client back....
0
 
Buropro-CitationAuthor Commented:
I would like to look into the TCP option further, I have started a test projet with IdTCPServer and the other with IdTCPClient, do you have a short sample code that shows how to make that channel you mentioned?
0
 
Sinisa VukCommented:
To not re-invent something... here is a good example ...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.