我可以实现从基于 WCF 的 HTTP 服务到 gSOAP c/Linux 客户端的回调吗?
我有一个 Linux/c 客户端应用程序,它通过 HTTP/SOAP (BasicHTTPBinding) 连接到 WCF Web 服务。我正在使用 gSOAP。我可以使用回调来实现对 Web 服务的调用吗?我想异步获取数据作为回调。
更新:我已经更新了问题标题。
I have a Linux/c client app that connects to a WCF web service over HTTP/SOAP (BasicHTTPBinding). I am using gSOAP. Can I implement the calls to the web-service using callback? I want to get the data asynchronously as call back.
Update: I have updated the question title.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
WCF 确实支持双工服务,或者能够回调请求客户端的服务。双工服务可能非常复杂,因为它们不仅是有状态的,而且还向客户强加了合同实施要求。
双工服务需要使用 WSDuplexHttpBinding。您将需要使用OperationContext 来获取对回调通道的引用。您的客户端必须在某个类中实现回调协定,并向客户端代理提供包含回调类实例的 InstanceContext。必须支持双向通信,如果客户端位于自己的防火墙后面或跨互联网,这可能是一个需要解决的复杂问题。编写双工服务时要小心……它们通常带来的麻烦比其价值更大……所以请确保您确实需要它。 ;-)
以下页面可能会有所帮助:
http://msdn.microsoft。 com/en-us/library/ms731064.aspx
WCF does support Duplex services, or those that have the ability to call back to the requesting client. Duplex services can be very complicated, as they are not only stateful, but they impose an contract implementation requirement on their clients.
Duplex services require the use of the WSDuplexHttpBinding. You will need to make use of the OperationContext to get a reference to the callback channel. Your clients MUST implement the callback contract in some class, and provide an InstanceContext that contains an instance of the callback class to the client proxy. Communications in both directions must be supported, and if the client is behind its own firewall or across the internet, this can be a complicated matter to resolve. Take care when writing duplex services...they are often more trouble than they are worth...so make sure you really need it. ;-)
The following page might be helpful:
http://msdn.microsoft.com/en-us/library/ms731064.aspx
basicHttpBinding 不支持回调。另一种方法可能是使用另一种客户端可以轮询响应的方法。
The basicHttpBinding does not support callbacks. Another approach might be to have another method that the client can poll on for the response.
我面临同样的问题,我尝试的方法是拥有一对 gsoap 服务器/客户端。基本上每个进程都会在端口上侦听肥皂调用,并向其他服务器发出客户端调用。这样我就避免了轮询或其他复杂的方法。对于实现的任何业务逻辑,代码显然必须是线程安全的,但客户端/服务器组合对是我迄今为止想到的最简单的解决方案。
显然,需要控制解决方案的双方,即提到的服务器和提到的客户端。
I am facing the same issue and the approach I am trying is to have a pair of gsoap servers/clients. Basically each process will listen on a port for soap calls and make its client calls to the other server. This way I avoid the polling or other complex approaches. The code has to be obviously thread safe for whatever business logic is implemented but the client/server combo pair is the simplest solution i have thought of so far.
Obviously one needs to be in control of both sides of the solutions the mentioned server and the mentioned client.