简体   繁体   English

如何在WCF服务中提供回调SOAP方法协定?

[英]How to Provide a Callback SOAP Method Contract in a WCF Service?

I have a WCF service which routes certain requests into a central processing application. 我有一个WCF服务,它将某些请求路由到中央处理应用程序中。 The WCF service uses basic HTTP/S bindings; WCF服务使用基本的HTTP / S绑定。 this is for compatibility with a variety of client technologies (Java, Python, etc.. .) 这是为了与各种客户端技术(Java,Python等)兼容。

I've been tasked with adding notifications to the service such that a client app (a service itself) can call one of the WCF methods with a URI as a parameter to be notified when there's a status change on the item that was sent in the original request. 我的任务是向服务中添加通知,以便客户端应用程序(服务本身)可以使用URI作为参数调用WCF方法之一,以在发送的项目的状态发生变化时得到通知。原始请求。 Basically, they call the service and give it a URI string in addition to the other data. 基本上,他们调用该服务,并为它提供一个URI字符串以及其他数据。 If/when the status of the data changes (which may happen days later or never) they should get a response DTO at the URI they gave informing it of the change. 如果/当数据状态改变时(可能在几天后发生,或者永远不会发生),他们应该在其给出的URI处获得响应DTO,以告知其改变。

The problem I'm running into is that implementing the proper publish-subscribe pattern is apparently not possible in WCF using the basic bindings . 我遇到的问题是, 在WCF中使用基本绑定显然无法实现正确的发布-订阅模式。 I can manually create a soap envelop and call out to the passed URI but I don't know how I can communicate the callback method contract the return service should implement via the service itself (so they can get it from the WSDL.) 我可以手动创建一个肥皂包,并调出所传递的URI,但我不知道如何传达返回服务应通过服务本身实现的回调方法协定(以便他们可以从WSDL中获得它)。

I can manually put together a requirements spec for clients making the call but I'd prefer to make it available in a way that the consumer services can get programmatically, so that it's always 1:1 with the WCF service itself. 我可以手动为发出呼叫的客户制定一份要求规范,但我希望以一种可通过编程方式获得消费者服务的方式使其可用,以便与WCF服务本身始终保持1:1的关系。

  1. Is there a better way to do this, keeping in mind I'm limited to the basic HTTP bindings? 有没有更好的方法可以做到这一点,请记住我仅限于基本的HTTP绑定?
  2. If not, is there a way to programmatically expose what the callback service method should look like? 如果没有,有没有办法以编程方式公开回调服务方法的外观?

You can use Duplex binding, but it will not work out-of-the-box for clients, other then .Net. 您可以使用双工绑定,但对于.Net以外的其他客户端,它无法即用。

For your UseCase, I'd consider to check usage of SignalR. 对于您的UseCase,我将考虑检查SignalR的使用情况。 It can be hosted inside your wcf service, and will be able to notify your clients. 它可以托管在您的wcf服务中,并且能够通知您的客户。

See also : SignalR as WCF web socket service . 另请参阅: SignalR作为WCF Web套接字服务

Also, I'd also check possibility of WebSocket usage 另外,我还要检查使用WebSocket的可能性

see 看到

http://www.codeproject.com/Articles/338789/What-s-new-in-WCF-4-5-WebSocket-support-Part-1-of http://www.codeproject.com/Articles/341413/What-s-new-in-WCF-4-5-WebSocket-support-Part-2-of http://www.codeproject.com/Articles/338789/What-s-new-in-WCF-4-5-WebSocket-support-Part-1-of http://www.codeproject.com/Articles/341413 / What-s-new-in-WCF-4-5-WebSocket-support-Part-2-of

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM