Best practices for using Wcf service from silverlight?

How would you structure the code to call the wcf service in a silverlight application?

Using only one single wcf service-proxy (aka singleton) deployed and using it throughout your SL application? If so, how did you decide to unsubscribe from the controls from the event ended by ws-call?

or

creating a wcf proxy service for every ws call? Where do you close proxies?

+3
source share
1 answer

Here is the structure of the application that I found workable:

  • The application is divided into modules (Prism, but can be anything) - a module into a vertical function.
  • Each module has its own set of client service classes (generated by slsvcutil)
  • , , IObservable.

    . GetAllMyDataAsync() GetAllMyDataCompleted, IObservable<MyDataDto[]> GetMyData(). / , , .

    , - :

    new MyServiceClient().GetAllMyData().Subscribe(DoSomethingWithAllMyData)

    , . ( , ):

    var des = (from d in new MyServiceClient().GetMyDataItem()
               from e in new MyServiceClient().GetDataItemEnrichment(d)  
               select new EnrichedData { Data = d, Enrichment = e});  
    des.Subscribe(DoSomethingWithEnrichedData);
    
  • (, , , ..), - .

    , MyDataService, MyDataServiceModel. , , . , viewmodels , ( MyServiceClient.GetAllMyData MyDataServiceModel.GetAllMyData.

    viewmodels WCF ( , ). , :

    • / DTO
    • ( )
    • , (, , - ), , , , - ) ..
    • , WCF, ,
+7

Source: https://habr.com/ru/post/1743529/


All Articles