Feeds:
Posts
Comments

Anyone of you experiencing STRANGE issues trying to connect to a Java web service –or- to embedded web servers (for instance sms gateways etc) ?

Well it could sound strange, but it happened 2 times in the same week here at my company and on totally different projects.

Basically it appears that if you send a POST using the HttpWebRequest sometimes the packets get fragmented on the IP protocol. This was NOT happening using the “old” XMLHttpRequest object of MSXML!

The actual point is that some web servers DO NOT LIKE the fragmentation. This TCP packet fragmentation introduce a wrong behavior of the web server that receives ONLY PART of the POST you performed. This leads to misunderstanding the actual request… and finally responding to you with errors or wrong behaviors.

It’s very hard to find this problem. The best tools that help understanding what is going on under the hoods are Network Protocol Analyzers such as Wireshark or Ethereal.

Some interesting lectures about that are:

Nagle’s Algorithm is Not Friendly towards Small Requests

If you want to solve the issue, use the following code:

 

Dim url As String = String.Format("http://{0}/smssend.cgi", txtAddress.Text)
Dim wr As HttpWebRequest = WebRequest.Create(url)
Dim msg As String = ".... .... ...."
Dim buffer As Byte() = System.Text.UTF8Encoding.UTF8.GetBytes(msg)

wr.ProtocolVersion = New System.Version(1, 0)
wr.Method = "POST"

System.Net.ServicePointManager.Expect100Continue = False
System.Net.ServicePointManager.UseNagleAlgorithm = False

 

Hope it helps!!

Adriano

Many times it could happen that you may want to update your definition while you have many workflows already running.

What happens? Well, if you change the definition and then resuming any workflow created with a previous version of the same, then you have 99% probability to get issues/exceptions (Murphy law again!).

This is normal, and I can explain why and how to work around this.

Why?

WF4 introduces a new persistence model which reduces the amount of data to serialize when persisting. This was a great improvement against the previous version of the framework because allows the framework to scale up better than previously.

However, it introduces the versioning issue, because if you added/removed some activities from your definition the persistence engine is not able to understand where to resume your workflow as well as the values of the variables/arguments at that stage.

There is also a logical issue behind that. You can’t assume that the new workflow definition is compatible with the new one.

Workarounds

You need to track all the versions of definitions that have running workflows into a table, for instance, and then provide your custom hosting for the workflow runtime so that you can deal directly with persistence engine and load the right version by your own. I already talked about that here:

https://adrianot75.wordpress.com/2010/11/04/wf4-persisnce-delay-and-execution-resume/

What is going to come

vNext will include Dynamic Updates on workflow resumption to help on this stuff. So the framework is going to provide a way to automate version redirection or definition “upgrade” automatically for you.

However, I guess “upgrading” can’t be done in any case, depends a lot on the kind of change you made. I think that this new feature will fall back to version redirection when not able to perform upgrade.

Sometimes it happens that you want to access Activity definition from your TrackingPartecipant implementation.

For instance, when dealing with “FlowSwitch” activities, you are NOT able to get the “name” of your Activity from the TrackingRecord itself, but you could reach further information using WorkflowInspectionServices against the definition and the ActivityID.

With DirectCast(record, ActivityStateRecord)

    ' extract actual activity...
    Dim activity As Activity =
        WorkflowInspectionServices.Resolve(WorkflowApplication.WorkflowDefinition,
            .Activity.Id)

    Dim ActivityName As String = .Activity.Name
    Dim ConditionExpression As String = String.Empty

    If TypeOf activity Is VisualBasicValue(Of Boolean) Then
        ' conditional statement...
        Dim conditionActivity As VisualBasicValue(Of Boolean) 

        conditionActivity = DirectCast(activity, VisualBasicValue(Of Boolean))
        ActivityName = "Condition"

        ' do something interesting... 
        ConditionExpression = conditionActivity.ExpressionText
    End If
...

Hope it helps!

I want to post some information regarding issues you can face with after MS updated the MarketPlace Developer Portal to the new Developer Hub.

We already had a Marketplace account activated, paid and active with a product too, but with the update it stopped working.

I mean I was able to login with my Live ID, but trying to look at the Developer Hub Dashboard I got an error saying I had to update my contact information on the XBox Live Portal… ?.

This sounded very strange, since I was not remembering to have created any XBox Live Account… after some research I found that for some reason I created some years ago an Account on this XBox Live Portal where I wrongly selected a Country different than the one I was having on the main Marketplace Professional Account.

I asked MS to change the Country because I was not able to do that on http://billing.microsoft.com website. No way, they forced me to CANCEL and CREATE a new Account on both Windows Live and XBox Live web sites to gain access to the Developer Hub!!

This created a lot of issues because I was explicitly requested to specifiy a different COMPANY NAME when creating the new Live Account…

All this because they didn’t wanted to change the Country on either Account… to match the REAL one.

Ok… I created the new account… but now I lost all the information linked to my previous “Live” account. VERY DISAPPOINTING.

VERY DISAPPOINTING.

VERY DISAPPOINTING.

Should I say it again?…I have to say that I was not expecting this kind of issues…

If you have a problem like this, remember that:

  • You may request MS for a refund IF you already paid for the Marketplace subscription in the current year.
  • Deleting your Live account you delete all related information (and MSN Messenger contacts too… so beware!)
  • You need to register AGAIN and pay the initial subscription to MS, like you did the first time
  • You need to re-create the products on the new Developer Hub

I hope you are not having this issue…

Cheers

When you rehost Workflow Foundation designer, sometimes it’s necessary for you to know the “scoped” variables to allow the user to choose from a list, for instance.

In order to make it you must navigate the Model tree from a given Activity (for instance the Activity bound to your Activity designer) using an helper method like this:

 

    ''' <summary>
    ''' Returns all the variables that the given scope could see... near->far ordering.
    ''' </summary>
    ''' <param name="Activity"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function GetScopedVariables(
                    ByVal Activity As ModelItem,
                    ByVal TypeFilter As System.Type) As List(Of ModelItem)

        Dim vars As New List(Of ModelItem)

        Do While Not Activity Is Nothing

            If GetType(Activity).IsAssignableFrom(Activity.ItemType) Then
                ' we found an activity now inspect the properties to find the "variables" collection
                ' note: this is only a suggested approach, but not the best/or standard one. 
                '       It means we are not able to get all teh variables that are created by other means.
                Dim propVariables As ModelProperty = Activity.Properties("Variables")

                If Not propVariables Is Nothing Then
                    ' now get all the variables into the variable collectio.
                    If TypeFilter Is Nothing Then
                        vars.AddRange(propVariables.Collection)
                    Else
                        ' take only the variables that respect the requested typefilter!
                        vars.AddRange(propVariables.Collection.Where(
                            Function(mi As ModelItem) As Boolean
                                Return TypeFilter.IsAssignableFrom(mi.ItemType.GetGenericArguments(0))
                            End Function))
                    End If
                End If
            End If

            ' get parent object....
            Activity = Activity.Parent
        Loop

        Return vars

    End Function

This method provides also type filtering, meaning that you get all scoped variables compatible with a given input type.

Hope this helps someone trying to do the same.

The new WF4 version is going to include a lot of enhancements both on the designer side workflow services definition versioning dynamic update…

Let me enumerate a few:

  • C# expressions
  • Errors when connectors not applied.
  • Annotations
  • Auto-connect (drag&Drop)
  • State Machine
  • Multi-assign
  • SQL/State machine activities previously on Codeplex are not include
  • Http Activities (POST/GET/…)
  • Dynamic Update (definition version recognition and update map)
  • Other stuff…

Great job guys!

Here at PAT we are developing, among many other things Occhiolino, a new BPM solution that initially will work for our applications, but targeted to be adapted to others by standard means (SOAP) as well as through custom connectors.

We built is using the new Workflow Foundation 4.0 shipped along with the .NET Framework 4.0.

We rehosted both the designer and the workflow runtime.

Designer

On the designer side, we customized the way the property editor behaves on the rehosted environment.

In fact, for a Business Analyst is not easy to write flows using the out-of-the-box behavior. If you need better design time support “for free” (aka Intellisense) you should have the Visual Studio IDE.

We are going to implement our Intellisense support, but this sounds not enough.

image

On the left-down-side we provided a property editor, that allows for each Expression Editor provide a context-specific expression. This is very powerful yet simple to use.

Well, we basically provide many property-specific features there:

  • List of compatible scoped variables and arguments
  • List of possible “expression templates” (where implemented by the provider).

The coolest thing is the this last one… “expression templates”. This is useful when you need to choose from predefined values, –or- when you need to choose from pre-defined expression types.

For instance, let’s take a quick example. Let’s say you have an activity “Change Ticket Status”. This Activity obviously have the property where to store the “Target Status”, right? Now, … in order to take advantage of arguments, we should have an expression editor there. But what IF the Business Analyst (BA) already knows its status and just like to write a constant value there? The BA needs to know the status code… and write it there.

We did better. We provided a “designer feature” that allows our property editor to gather a list of expression templates from the “Ticket Status Property”.

We can also provide a variable-creation logic, which is more simple. By pressing Create New Variable button you come to a “new variable” form where you define the name and choose a compatible type (in this case the type does not have other compatible types so the list is locked):

image

The UI here is MUCH more simpler to use that the out-of-the-box one. Because we add also human-readable description for the types (provided by some designer attributes we apply to types), and filtering on both description and type name.

Workflow Execution Monitor

From the designer console, you can see the workflow queue updated in real time:

image

We also provided a debugger feature that allows the user to display from the designer, the status and the trace of all the execution along with parameters.

image

This was done adding a TrackingPartecipant that stores the history on our own table, that, in turn, is displayed on this page.

Server

We host all our services on our own WCF services. We have one administration service that allows the designer to perform all the “designer/administration” stuff.

We also provide a “Client” service that allows external applications to connect to the “Events” where our Workflow Definitions are attached.

We track versions of the same definition – in order to maintain compatibility with workflows already started – and also we provide Persistence support to all our workflows.

Human Interaction

We provided a metadata-driven set of clients that allows the user to provide data to flows at any stage required by the Business Analyst:

image

All this stuff is interfaced externally to the End-users through:

  • A “traylet” Windows-application
  • A multibrowser lightweight web application where the end-user could provide answer and make the flow continue with the results.

image

We are going to provide in the future, “Human Interaction Clients” for other platforms, such as WP7, IPhone, Android.

I’ll provide further details on the persistence and provider-independence of this solution in a next post!

Keep tuned!