Calling the AppraisalManagementService Web Srvice

Topics: CAB & Smart Client Software Factory
Apr 26, 2006 at 12:52 PM
originally posted by: optimism99

I am looking at the AppraisorWorkbench sample project. I want to call the AppraisalManagementService Web Service.

(I am new to the Smat client BAT)

I am curious, when I call the methods of the AppraisalManagementService web service, where do I call them from ??

After looking through the documentation I see two possible places to call the web service and it's methods.

The possibly places to make the call are from the :

AppraisalDetailViewPresenter class

Or the :

AppraisalDetailView

So of those two where should the call be made.

Second question. In general if I want to make the call to the web service, from another C# file, should I just plan on wiring up the WorkingAppraisalSelectedHandler (Event Handler)

I would deeply appreciate someones help. As I mentioned, I am new to the SMART Client BAT toolkit. So many things are fuzzy right now.

Thanks in advance,
Will
Apr 26, 2006 at 5:56 PM
originally posted by: matiaswoloski

The pattern used in SCBAT is the MVP (Model View Presenter). The webservices are being called from the presenter. You can call services from the view, you don't have any constraint regarding that, however, it will make your view dependent on the service. It's a matter of separation of responsabilities. If you use MVP, among other things, you will be able to do TDD against the presenter using a mock view (a view that mimic the functionallity of the smartpart but is not a usercontrol).

In SCBAT the webservices are not being called directly using the generated proxy. Indeed, there are two layers above the proxy. The first one is a small library that allows you to enqueue the calls to the webservice using the Command pattern. Then you will find the Service Agents. These agents implements the offline logic and the mapping between business entities on the client and the returned DTOs from the service.

In the presenters you will see code like this:

InjectionConstructor
public AvailableAppraisalsViewPresenter
(
ServiceDependency IAppraisalManagementServiceAgent appraisalService
)
{
_appraisalService = appraisalService;
}


This code will inject the instance of the AppraisalManagementServiceAgent. This service was registered to the WorkItem (container) using this code:

WorkItem.Services.AddNew{AppraisalManagementServiceAgent, IAppraisalManagementServiceAgent}();

The instance will be available to the presenter via _appraisalService. For example, you will find this call to the webservice

public void ShowAvailableAppraisals()
{
_appraisalService.GetAppraisals(AppraisalFilter.Unassigned, delegate(bool success, Appraisal[] appraisals)
{
if (success)
{
_view.SetAppraisals(appraisals);
}
else
{
if (StatusUpdate != null)
{
StatusUpdate(this, new EventArgs<string>("Cannot get list of unassigned appraisals"));
}
}
});
}

Notice that is not a regular call to a webservice proxy.

It gets time to learn CAB, but when you learn it you will find lot of flexibility. If you need more clarification don't hesitate to ask.

Matias
http://staff.southworks.net/blogs/matiaswoloski
Apr 27, 2006 at 7:05 AM
originally posted by: msimitpo99

I appreciate your help. This project has been thrown on my lap, and their is major pressure to get it done. I have limited time to come up to speed with the whole Smart Client BAT toolkit. So more help is deeply appreciated.
I just found out that the call to the Web service must be made from our data services layer.
How would I go about calling the web service from the data services layer?
Apr 27, 2006 at 5:23 PM
originally posted by: matiaswoloski

Technically speaking, you can call a webservice from wherever you want. I don't know what's the meaning of data services layer. In the SCBAT reference implementation you will find these layers:

CAB (SmartParts, WorkItem, Workspaces, etc.) - Presentation Layer
Service Agent Layer
WebService Proxies Layer
|
|
WebService Layer
Data Access Layer
Sql Server

So, calling a WebService from the DAL would mean that you need to get data in your backend from external sources and expose it within your webservice layer.
I would try to encapsulate the database calls in the Data Access Layer and have another Service Agent Layer in the backend to communicate with those web services.

Anyway, this doesn't seem related to CAB or SCBAT unless I am missing what you mean by data services layer.

Thanks,
Matias