开发者

Create custom channefactory for dynamically calling workflows

I need to create a custome channel factory for calling WCF Wrokflow services hosted in the IIS. At runtime only i will be able to know which workflow should be called a开发者_运维技巧nd which method need to be called. Can anyone help with an example for the same?


What information about the workflow service(s) do you have at the client? If you have the contract (service contract, such as one generated by svcutil / add service reference when pointed to the xamlx service) and the endpoint address, then you can simply use the channel factory directly. For example, the default "WCF Workflow Service Application" declares an endpoint at the xamlx address, with basicHttpBinding.

string address = "http://localhost:27962/Service1.xamlx";
Binding binding = new BasicHttpBinding();
ChannelFactory<IService> factory = new ChannelFactory<IService>(binding, new EndpointAddress(address);
IService proxy = factory.CreateChannel();
var result = proxy.GetData(new GetDataRequest { @int = 1234 });

If you don't have the contract / binding, you only have the xamlx address, and you want to create a proxy dynamically at runtime, you can use something like Vipul's dynamic proxy to create the proxy during runtime, and call the service operations using the dynamic proxy methods.


Vipuls dynamic proxy (http://blogs.msdn.com/b/vipulmodi/archive/2006/11/16/dynamic-programming-with-wcf.aspx) work perfectly.. Thanks man..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜