I am looking into doing a project which would involve php and c#. What I need to do is from PHP the user can perform a certain task and once php has processed some information, this information needs to be sent to a c# application and c# can do some other work with the information provided.
The c# application would most likely work from the same server that the php web app is running from but it should work if they are on completely separate servers.
I guess I could send some XML from php to whatever IP address that the c# program running on, but have no idea how I would get php to do the sending and the c# app to do the listing for the data.
Any help would be greatly appreciated.d
In one acronym, you have the solution to (almost) any interoperability problem in your life.
"Simply" define a web service running in a desktop application (it is possible but it's not that straightforward) and instantiate a PHP SoapClient.
Of course you can send direct XML input to your desktop application. This makes use of .NET Socket (System.Net.Sockets
) and PHP socket I/O (fsockopen
). You can create your application-specific protocol and inject the XML data.
Recommended if you are already very familiar with XML and comfortable to sockets. Unrecommended if you want a higher level of reusability.
You don't specify the nature of the data you're sending but if you're sending it across the web, then using language-independent methods such as XML, JSON, web services and the like means your server-side languages are largely irrelevant.
If you're sending something like huge movie files, however, then you'll probably be better off using FTP or similar.
You could open a WCF channel in the C# service and then call into it with PHP.
You should host a self host WCF service in your desktop application and call the services from your php application.
using System.ServiceModel;
using System.ServiceModel.Description;
sample code:
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
string SayHello(string name);
}
public class HelloWorldService : IHelloWorldService
{
public string SayHello(string name)
{
return string.Format("Hello, {0}", name);
}
}