Nick Gotch
Nick Gotch

Reputation: 9407

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. The WCF service uses basic HTTP/S bindings; this is for compatibility with a variety of client technologies (Java, Python, etc.. .)

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. Basically, they call the service and give it a URI string in addition to the other data. 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.

The problem I'm running into is that implementing the proper publish-subscribe pattern is apparently not possible in WCF using the basic bindings. 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.)

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.

  1. Is there a better way to do this, keeping in mind I'm limited to the basic HTTP bindings?
  2. If not, is there a way to programmatically expose what the callback service method should look like?

Upvotes: 0

Views: 781

Answers (1)

evgenyl
evgenyl

Reputation: 8107

You can use Duplex binding, but it will not work out-of-the-box for clients, other then .Net.

For your UseCase, I'd consider to check usage of SignalR. It can be hosted inside your wcf service, and will be able to notify your clients.

See also : SignalR as WCF web socket service.

Also, I'd also check possibility of WebSocket usage

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

Upvotes: 1

Related Questions