douyin9987 2013-01-24 17:09
浏览 51
已采纳

如何从PHP发送通知到C#服务?

I have a Windows service written in C# that handles processing of digital documents, and a web application written in PHP. I need to be able to notify the C# service that new documents are ready for processing.

Currently, the C# service is reading the MySQL database every 10 seconds to see if there are new tasks to be performed. This creates a 10 second lag in the responsiveness of the web application. I'd like to be able to trigger the C# service immediately when the document is ready.

I'm looking for an answer that will allow PHP to notify the C# service without any delay.

Here are some possible ideas that I've had;

  • Use a shared memory object between PHP and C#, and have a thread in C# wait for that object to be signaled. Is this possible with PHP?
  • PHP connects to C# using a socket on localhost, sends a nak and disconnects. This seems inefficient to me.
  • Configure MySQL to use an in-memory table, and have the C# service query the table every second.
  • Is it difficult to create some kind of web service in C# that uses XML or SOAP, and would there be any lag (+1 second) in calling that service via PHP?

That's all I can think of. Maybe there is some kind of standard way this should be done, and I'm just not aware of it.

  • 写回答

3条回答 默认 最新

  • doushen9863 2013-01-24 17:24
    关注

    It'd be pretty trivial to make a REST facade in WCF that triggers your c# service on a POST against /. Security can be layered on depending on the nature of your deployment.

    http://msdn.microsoft.com/en-us/library/bb412178.aspx

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助