2012-06-06 64 views
0

我有一個域服務類,它包含一個簡單的POCO對象和一個包含2個變量a和b的類以及構成它的方法。查詢到wcf ria服務調用

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; 

     } 

     } 
} 

我想學習,如何在silverlight的mainPage上調用這個wcf ria服務?

回答

1

你可以打電話給你的Silverlight的端服務是這樣的:

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

DomainService1 domainService = new DomainService1(); 
domainService.sum1(Sum1Completed, null); 

(...) 

void Sum1Completed(InvokeOperation<int> op) 
{ 
    //op.Value has the result 
}