WCF callback + WF4 - wcf

How to call duplex wcf callback service in WF4. Please give a simple example

WF4 has no direct for normal duplex WCF services. Because of the often long running nature it uses something called durable duplex services which is basically the original caller also being a full WCF service. See here for a blog post on how to set this up.
If you want to support regular WCF duplex services you would need to create a custom activity and implement it using regular C#/VB code.

Related

Silverlight duplex with WF

I have read the below article and it would seem that it's not possible to use duplex communications to a WF from a silverlight client.
Is this really the case? Are there not a work arounds to this? If not, I find this a strange omission.
http://msmvps.com/blogs/theproblemsolver/archive/2010/05/03/workflow-4-services-and-duplex-communications.aspx
Thanks
Mike
The reason Silverlight doesn't cut it as a client for WF4 duplex communication is the long running nature of workflows. WF4 reasons, correctly, that a client will not be around for the entire duration of the workflow so the normal duplex channel, which relies on the client keeping the proxy object alive, is not good enough. So WF4 uses durable duplex where the duplex callback is really a completely separate call and doesn't rely on the original proxy object. But the result is that it requires the client to be a WCF ServiceHost and therefore full WCF stack. And of course Silverlight only contains the client part of the WCF stack and not the ServiceHost as that is normally not needed in the browser.
As far a workarounds go. If you know your workflow isn't around for a long time you can use the Silverlight polling duplex to communicate with a standard WCF service and have that communicate with the duplex workflow.
But that said, it makes the architecture quite a bit more complex and duplex WCF is already a complex and error prone beast so I would only do this when really needed.

How can a I publish data to a WCF duplex service, from non-Silverlight client

I have a Silverlight app, that uses a WCF duplex service extensively (therefore I don't want to change from duplex on that side of things).
I wish to stream data from a Windows app, via the WCF duplex service to any connected Silverlight client. However I believe that only Silverlight clients have an API to call duplex WCF services (based on PollingDuplexBindingElement).
Therefore, I thought perhaps that I could have a non-duplex WCF service on the same website,to which the Windows client pushes data, and somehow trigger the duplex service to forward on the messages. But to start with, the non-duplex service is effectively a windows app as well and gets the same errors if it tries to call the duplex service.
Finally, I have concluded I will have to use a shared queue / bus between the services and would like recommendations as to a good approach. I am looking for the best performing (low latency) solution.
The link below there is a good sample which consumes a wcf duplex service from a wpf client.
http://petermcg.wordpress.com/2008/11/19/silverlight-polling-duplex-part-4-wpf-client/

WCF Service to WCF Service Communication

I am trying to create a number of WCF services. These services will expose certain public methods and require to consume each other (i.e. call WCF Service methods from another WCF Service)
Is there any good reference tutorial material that I can refer to for this?
Thanks all in advance!
Consuming a web service in another web service is no different to consuming it in any other client. You create a proxy and make your call so all the general WCF documentation and tutorials will apply.
However, this is usually not a good practice - although sometimes is unavoidable in an SOA. Services must be consumed by clients and they should not call each other unless they have to.
There are a host of problems that can happen. First of all, a service has to wait for the result of a synchronous call from one or more services to return and your service thread will be locked until those calls are finished. If one call takes long, the other service will take long as well and you will have scalability issues.
Let the client call these services. If a call requires data from another service, get the client to make the call and get the data and then make the call again.

RESTful Workflow Service Endpoints in WF4 / WCF

Folks,
I'm building a pretty standard workflow that I want exposed via a WCF endpoint - I'm using the "WCF Service Application" project template and I've got a .xamlx service. This is a very simple document interchange workflow service - I want consumers to POST me a blob of XML as the body of an HTTP post (with HTTP headers containing authentication tokens). In response, these consumers will get a blob of XML containing the reply. 2 goals for me using REST/POX here are the document/message-based nature of the interaction AND I want to make client development easy for non-.NET environments (especially limited environments like Silverlight and iPhone).
I don't really see how to make this possible using out of the box features (unless I'm missing something). Does anybody know how to create a RESTful (or even REST-ish, I'm not picky) endpoint for a WF4 service-hosted workflow? Any info leading in the right direction here would be great.
There is an unreleased item on CodePlex to cover this, which includes source code. Also see this SO answer which contains another idea for achieving this.
If you'd like to see the CodePlex activity released, please up-vote the UserVoice request.
Using a REST Pass-Through Service
As #Maurice mentions, you can also treat the WF service as a back-end service and expose a REST service that simply calls through to the WF service.
This method is a bit clumsy, but has the advantage that it doesn't use anything unreleased or really complicated.
If the back-end service runs on the same machine as the REST service (which is probably what you'd do), you should expose the WF service using the named pipes binding. This binding is fast, but only works when the caller and callee are on the same box.
A further thought: your REST pass-through service is blocked while the back-end service is being called. If your WF service is not very fast, you'd benefit from making your REST service asynchronous so it doesn't block a thread pool thread while the WF service is being called.
There are no out of the box activities that will allow you to use REST with WF, the Receice is pure SOAP.
You can either build a custom REST Receive activity and use that with your workflow. Depending on your needs this is going to be quite a handful to a lot of work. The easy option is use use a standard REST WCF endpoint and convert the REST data to SOAP, pass rhe request on to the workflow, and do the reverse on the result message.

Reverse WCF that will connect to a non .net tcpip application

I am new to .net and am trying to use c# as the basis of my .net learning. I have a project where I need a service to connect to mutliple tcpip applications that are a 3rd party application written in vb6. Someone has mentioned using WCF as the base, but i'm not sure how it would make an outbound connection (instead of receiving incoming ones) to a non .net application? Please help
With C# and WCF, you can either create:
a WCF service which will offer up some functionality that other applications can call
or:
a client that connects to some other SOAP or REST service to consume functionality.
So which one is it you're looking for??
Also: WCF is a SOAP or REST based service stack - you cannot use it to connect to low-level TCP calls (socket programming). Your "other" side must understand either SOAP (the web service protocol) or REST (the URL-based lightweight protocol). If you other sides don't speak neither SOAP nor REST, you're out of luck and can't really use WCF for that.
You'll have to deal with socket programming, WCF won't help you here.
Try reading this: http://www.codeproject.com/KB/IP/socketsincsharp.aspx