简体   繁体   中英

Add web reference to silverlight application

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

I can only add service 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM