开发者

Add web reference to silverlight application

开发者 https://www.devze.com 2023-04-10 13:52 出处:网络
I\'m new to silverlight, I want to add web reference to silverlight application is that possable??? I can only add se开发者_如何学JAVArvice reference to the SilverightApplication but i want to add we

I'm new to silverlight, I want to add web reference to silverlight application is that possable???

I can only add se开发者_如何学JAVArvice reference to the SilverightApplication but i want to add web reference.

I can add web reference to the SilverightApplication.Web, can i use it from SilverightApplication??

I aslo can add service reference to the SilverightApplication but functions of service reference has no return value so i cant recieve the data, here is the code Service1SoapClient c = new Service1SoapClient();

        ServiceReference1.Service1SoapClient a = new  ServiceReference1.Service1SoapClient();
        a.returnStr_19_9Async("");

the function returnStr_19_9Async("") has no return value can any one please tell me what is teh wrong?? Can you please tell me how, please explain..

Thanks.


The problem you may be striking is that WCF calls are all done asynchronously in Silverlight. This means when you call your initial service function (let's call it GetMyClient(int clientId) ), the proxy that you have generated will have a function called GetMyClientAsync(), and it will also have an event called GetMyClientCompleted which you must subscribe to:

myProxy.GetMyClientCompleted += new EventHandler<GetMyClientCompletedEventArgs>(MyProxy_GetMyClientCompleted);

that event handler will look something like this:

private void MyProxy_GetMyClientCompleted(object sender, GetMyClientCompletedEventArgs e)
{
    //e.Result will have your returned values
}  

This is just a very brief overview that gives you enough to get started. You could also read more here: Silverlight.net | Data & Networking | Network Services (Soap, REST and More)

0

精彩评论

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

关注公众号