Search code examples
wcfsilverlight-4.0wcf-ria-serviceswcf-client

query to wcf ria service call


i have a domain service class which contain a simple POCO object and a class which contain 2 variable a and b and the method which make sum of it.

public class DomainService1 : DomainService
    {
        abc obj = new abc(10, 20);
        public int sum1()
        {
            return (obj.a + obj.b); 

        }

    }
    public class abc {
        public int a { get; set; }
        public int b { get; set; }


        public abc(int c, int d)
        {
            a = c;
            d = b;

        }

        }
}

I wish to learn, how can i make call to this wcf ria service at the mainPage at the silverlight?


Solution

  • You can call your service on silverlight side this way:

    DomainService1 domainService = new DomainService1();
    domainService.sum1((op) => 
    {
        //op.Value has the result
    }, null);
    

    or

    DomainService1 domainService = new DomainService1();
    domainService.sum1(Sum1Completed, null);
    
    (...)
    
    void Sum1Completed(InvokeOperation<int> op)
    {
        //op.Value has the result
    }