How can I Manually create a client proxy for a WF4 (xamlX) Service

I've created several services by wrapping the WorkflowServiceHost in a WCF service; using WorkflowHostingEndpoint. Doing this I was able to define my service contract and create proxy classes to connect to those services.

I'm now creating a service in which I want to use the WF4 messaging activities and again self host the service. I also REALLY want to manually create my proxy classes without using the ServiceReference in VS2010 or ServiceUtil...

I've seen some references that use the Send Activity in the Service client but I'd like to be able to use a more "WCF-like" proxy created directly against the service contract like I've done with the other services. How can I do that? Is there anywhere a xamlX (or xaml with messaging activities) stores the interface contract that I can use to generate a proxy manually?

NOTE: I don't want to use the Send activity as described in the WF_WCF_Samples.

UPDATE: I tried creating an interface identical to the workflow receive activity before posting this question; but I keep getting the following error:

The message with Action 'http://tempuri.org/ISvrClientService/Create' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, eg Message, Transport, None).

Thanks!


There is no need to use the Send activity. When you host a workflow service you are hosting a SOAP endpoint, the only difference is the implementation but that is a private detail. You can create a proxy object using ChannelFactory just like with any other WCF service.

var factory = new ChannelFactory<IYourService>();
var proxy = factory.CreateChannel();

The IYourService interface is somethign you have to hand craft. There isn't one on the server, it is done in a workflow, so you have to code up the identical contract.


I've done this successfully with channel factory and manually created interfaces. The trick was in matching-up the reply/send in/out parameters names not just type signature.

This is particularly crucial if you have bookmarks with correlation in your workflow.

链接地址: http://www.djcxy.com/p/95852.html

上一篇: 使用Pick活动显示多个服务接收

下一篇: 我如何手动为WF4(xamlX)服务创建客户端代理