开发者

Is it possible to generate WCF async service contracts for Silverlight on runtime?

I have a WCF service contract that reads like:

    [ServiceContract(Name = "DummyService") ]开发者_如何转开发
    public interface IDummyService {

        [OperationContract]
        void DoSomething();

        [OperationContract(Name = "SayHello")]
        string SayHello(string message);
    }

The WCF service will be consumed by a Silverlight application. I'm finding a way to eliminate the need to manually write async contracts just so I can consume this through a proxy generated by ChannelFactory.

I'm thinking of writing a specialized invoker class. Sample usage is as follows:

// create the invoker using the endpoint config and the existing sync contract
var client = new ServiceInvoker<IDummyService>("LeyDummyService_Endpoint");

// invoke the desired service method set the callback, very similar to how 
// JQuery does AJAX calls...
client.Invoke(dummyService => dummyService.SayHello("harley"),
             (result) => MessageBox.Show(result));

Have anyone tried this? Is this even possible?


Have you tried using Svcutil? It will compose all the async contracts for you.


Totally possible http://servelat.codeplex.com/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜