13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

{// Propertiesprotected SalesDataProvider m_dataManager;// Constructorpublic ServiceSalesProvider(){m_dataManager = new SalesDataProvider();}// GetSalesReportpublic DataSet GetSalesReport(<strong>in</strong>t theYear){DataSet ds = new DataSet();ds.Tables.Add(m_dataManager.GetSalesReport(theYear));return ds;}}// GetSalesReportBarChartpublic str<strong>in</strong>g GetSalesReportBarChart(<strong>in</strong>t theYear){return m_dataManager.GetSalesReportBarChart(theYear);}The SalesDataProvider protected member is <strong>in</strong>itialized only once, when theServiceSalesProvider class <strong>in</strong>stance is constructed. After that, any call to the variousmethods is resolved us<strong>in</strong>g the same <strong>in</strong>stance of the helper class.The ServiceSalesProvider class has two public methods with the same names as themethods <strong>in</strong> SalesDataProvider. The implementation of these methods is straight<strong>for</strong>wardand fairly self-explanatory. The only aspect worth not<strong>in</strong>g is that the remotableGetSalesReport method adds the DataTable object returned by the correspond<strong>in</strong>gmethod on the SalesDataProvider class to a newly created DataSet object. TheDataSet object is then returned to the caller.NoteWhen writ<strong>in</strong>g remotable classes, be sure that all the methods useand return serializable classes. No extra steps are required if youdecide to write your own, user-def<strong>in</strong>ed classes as long as they<strong>in</strong>clude SerializableAttribute or implement the ISerializable <strong>in</strong>terface.Publish<strong>in</strong>g the Remote Service ComponentTo be usable <strong>in</strong> a distributed environment, a remotable class must be configured andexposed so that <strong>in</strong>terested callers can reach it. A remotable object needs a runn<strong>in</strong>ghost application to handle any <strong>in</strong>com<strong>in</strong>g calls. In addition, the object must specify whatprotocol, port, and name a potential client must use to issue its calls. All requirementsthat callers must fulfill are stored <strong>in</strong> the remote object's configuration file.438

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!