Sample adapter service

Access or adapter services enable access to certain data. In our sample scene, we have at least one adapter or access service. We have a business process in the accounts department, which gets a list of external expenses from a third-party system through files in some format (let's say, XML or CSV). So, a web service is required, which receives the files one by one, parses the files, and saves them in the database.

Since we are discussing the SOA architecture, and not coding the web services, from now on, we will only see the example pattern, and have a suggestive skeleton service.

Our sample indicative implementation for a file receiving adapter service would look like the following:

    /// <summary> 
/// Receives the external expenses file and save it to
Accounting database.
/// Case when file comes from another web service
/// Type: Adapter Service
/// </summary>
[HttpPost]
public void Post()
{
if (Request.HasFormContentType)
{
var form = Request.Form;
foreach (var formFile in form.Files)
{
var filePath = Path.GetTempFileName();
using (var fileStream = new FileStream(
filePath, FileMode.Create))
{
formFile.CopyTo(fileStream);
}
//1. Parse the uploaded files
//2. Save the data into database using data access layer
//3. Delete the temp files
}
}
}

In the Sample Business Processes for Departments section given earlier, we have the following examples of access service:

  • The first example is the one that is able to communicate with third-party B2B services able to receive the Passport document after its renewal from government authorities to the Regulatory Affairs department.
  • The second is the one in which the received document is sent from the Regulatory Affairs department to the HR department.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.57.172