When using WinFX Feb CTP and building workflows based on it after a while the question arises: How to integrate Windows Communication Foundation (WCF) based services with Windows Workflow Foundation (WF)?
Looking at the available activities coming with WF there is one which seems to be a good candidate: InvokeWebService.
So I built a WCF Service with a data contract (separated from the service implementation in an own assembly named OrderContract, defining two classes: Order and OrderItem which is used by Order) and hosted the service on IIS. This should work well with the InvokeWebService-activity from WF. The service provides one method submitOrder(OrderContract.Order).
Next step was to implement a simple sequential workflow containing one activity to invoke my WCF service.
I added a private member of type OrderContract.Order to the workflow cause I want to link that member with the parameter needed by the WCF service method submitOrder(OrderContract.Order).
Adding the InvokeWebService-activity to the WF starts a wizard which tells me to specify the URL of the service. I specify the URL and choose a name for the Web Reference. Done this I specify the method of the service to invoke by the activity and its properties (two for the result and one for the parameter of type OrderContract.Order).
Surprise: The property window doesn't allow me to assign my private member of type OrderContract.Order to the parameter-property of the service's method.
Reason: The wizard generated a proxy (including the data contract information) for the service in a namespace with the name of the Web Reference. So for the WF activity the private member and the property are of different type cause they reside in different namespaces.
Solution: Renamed the Web Reference so that it has the same name as the assembly containing the data contract (OrderContract).
That results in identical namespaces and I can assign the private member to the property.
The better approach is to generate a proxy client for the WCF service using the svcutil-utility because it enforces the WCF paradigm of separating business logic and transport. The proxy client can be used in a WF code activity. The service configuration information for the client has to be added to configuration file of the application hosting the WF.
Attached you can find the two solutions I used for the scenario with the InvokeWebService-activity.