views:

300

answers:

1

Our workflow in Workflow Foundation used to call ASMX web services using the InvokeWebService activity, which has a property SessionId to correlate multiple activities in the same session (by sending the ASP.NET session cookie on every request). It worked.

Now we have switched to WCF web service interface, and we have changed our workflows to use the SendActivity activity instead. However, we haven't found any solution to correlate the web service invocations, i.e. sending the session cookie on every request.

Is it possible to achieve this in WF, or do we need a custom solution?

A: 

I am not aware of any built-in facility for handling cookies in any of the WF/WCF integration activities (SendActivity and ReceiveActivity). This makes sense since WCF is transport-agnostic, and therefore at a high level the APIs cannot be coupled to any HTTP-specific features like in the case of ASMX Web Services.

A solution in your case could be to expose the WCF services through an endpoint that uses the basicHttpBinding, which is compatible with the protocol supported by ASMX Web Services, and then revert to using the InvokeWebServiceActivity to invoke them.

Also, since a WCF service can be exposed through any number of endpoints, you can simply add an endpoint that uses the basicHttpBinding to the ones that are already there. Here is an example:

<configuration>
    <system.serviceModel>
        <services>
            <service name="MyNamespace.MyServiceImpl">
                <endpoint binding="wsHttpBinding" name="WsHttp"
                    contract="MyNamespace.IMyService" />
                <endpoint address="basic" binding="basicHttpBinding" name="BasicHttp"
                    contract="MyNamespace.IMyService" />
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost/myservice" />
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>
</configuration>

Then the workflows that use the InvokeWebServiceActivity would invoke the service using the following URL:

http://localhost/myservice/basic

Enrico Campidoglio