WCF Workflow service application and state machine in WF 4.0 - wcf

I am working a project where i need to create a state machine work flow in 4.0. I have installed .net framework 4 platform updates and i am able to get state machine and states in toolbox to work with.
I have created a WCF workflow service application. I have currently 3 states in this.
State1 which executes a extenal process.
State2 which updates a database.
State3 populates some entity class.
Each state will be having a receiveandsend activity. I need to trigger each states individually from client. Cancreateinstance of each receive activity is made true.
I have to call this from a silverlight application. So i have added the service referance to this workflow in silverlight application.
when i execute the first state, its works fine and external process is executed.
But when i try to execute the next state by calling the next receive activity from client, its showing error as below.
"Operation 'ExecuteExternal|{http://tempuri.org/}IService' on service instance with identifier '4732d197-32c0-4591-87bc-fa0adb7ec43a' cannot be performed at this time. Please ensure that the operations are performed in the correct order and that the binding in use provides ordered delivery guarantees."
I think the WF is not waiting after first state is finished. Can anyone help me to solve this?

Your state machine is not waiting for the message that you are sending. The best way to troubleshoot this is with tracking. I've added a behavior that will help you to Microsoft.Activities. See my blog post Using Workflow Services and Silverlight Together

Working with Correlation handle helped me to solve this issue.
Please find the answer in the below post
http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/6a7d9069-d5a7-4410-b5dd-16325d0d8dc9

Related

WCF - quick response with status then continue doing longer process

I spent few days search on this case. I checked out all wcf asynchronous implementaions.
I wasn't able to find what I was looking for.
Below is scenario.
WCF is running to accept xml
WCF needs to response to user for success receiving xml and release
the request immediately
WCF then needs to do processing to save xml to database and parsing xml to
convert something else.
I don't want to use separate service to process above. I want to use one service to handle all 3 cases above.
I checked out asynchronous way of coding in WCF, but this doesn't release the request right away. What is the best practice for this? Is there any sample code I can use?
Thank you in advance.
I think you would be better suited to using a different technology. Maybe look at Windows Workflow Foundation.
You can host WCF Workflow Services the same way as you host a standard WCF service, the main difference is that you can create specific workflows that can continue after acknowledging receipt of the original message.
You do this by persisting the message and returning to the user. WF allows you to create actions that continue after sending response back to the caller.
Visual studio provides you with a design surface that allows you to drag and drop components to create custom workflows. Additionally you can also make calls to other services if required.
With .net 4.5 you can now use C#, in previous versions of WF you had to use VB.net.
You can read about it on the MSDN site here:
http://msdn.microsoft.com/en-us/vstudio/jj684582.aspx
Hope this helps

Event Aggregaotr for ASP.NET MVC

I need something like EventAggregator in WPF PRISM but for ASP.NET MVC4.
I have following problem. When some action is done, for example commend is added, I need to send 2 mails and SMS message. Now I would like to take it off comment processing action, and to do it somewhere in the background.
One way I could do it is to subscribe to events in Global.asax, and than to execute list of subscribers for specific event when needed (by creating IEventAggregator, using dependency injection, like in PRISM). But then, it will run in same thread as comment processing action.
Is there any other way, and are background tasks and background workers even possible in ASP.NET MVC4?
NOTE: Currently I can't create separate services (WCF for example), which would do that work, because site is running on shared hosting.
hm, have you hear about signalR (background tasks r possible)? http://www.asp.net/signalr/overview/getting-started/introduction-to-signalr

ObservableCollections are no longer returned when I update my service reference

I have a Silverlight 5 app. This app has been in development for 18 months. This app calls back to a WCF service. I just had a support request.
Before today, the service would return ObservableCollection<T> results. However, now all of the sudden, out-of-the-middle of nowhere, it starts returning T[] results after I updated the service reference in the Silverlight app.
My question is, what could have happened that would cause this change? This has caused approximately 70 errors due to type conflicts. Am I overlooking a basic setting?
Thank you!
If you're using a service reference to communicate with the service, make sure the Data Type hasn't been changed. Right click on the service in the Service References folder, select Configure Service Reference..., and look at the Data Type - Collection type:. If it's System.Array, then this may be your problem. Change it to ObservableCollection and see if that helps.

WF 4 Workflowservice with State Machine

I'm currently working on a project where we want to implement a WF4 state machine as a workflowservice. The fundamentals seem to make sense as we've used WF 3.5 in the past. However one issue we've come across is that we'd like to be able to create an instance of the workflow at any of states (or at least more than just one of them). Selecting the CanCreateInstance property on more than one Receive activity throws an exception.
I've played around with Maurice's suggestions on correlation from his blog but haven't been able to figure out how to apply that to a state machine.
We have a sample that might help you Windows Workflow Foundation (WF4) - Silverlight / State Machine Workflow Service

WCF Workflow Service single instance correlation

Using visual studio 2010 RC/.Net 4.0
I have a wcf workflow service with three receive activities defined, basically StartProcessing, StopProcessing, and GetProcessingStatus. This is a long running service that continues to poll an external service for data once StartProcessing is called, until StopProcessing is called.
My problem is with figuring out how to use correlation to ensure that all calls into the service call the same instance of the workflow. I am trying to avoid requiring any sort of instance id be required to be passed back in to subsequent calls to the service. In a nutshell, I would like the workflow being executed to be a singleton, and ensure that all receive activities operate on the same instance. How do I go about doing this?
You can correlate on a constant for example. Edit the XPath in query correlation to return the number 1 for example.
I think that what you want is impossible, you need to correlate, WWF does not know how to execute it. If two parallel calls are received they will use the same object with unexpected results.
In wcf it could be possible, you can set a session in the client or you could manage wcf object creation, but in WWF I think you even don't have that options.