The Provided Sample Implementation
To complete the service, we need to implement the method getDayofWeek() in the service implementation. For the purposes of this example, we will use the provided sample implementation DayOfWeekPortTypeImp.cpp rather than editing the above generated one. The provided implementation implements the getDayofWeek() method using class rwsf::DateTime which provides a method that returns the day of the week for any valid date.
Let’s look at the code. Here’s an excerpt from the provided implementation DayOfWeekPortTypeImp.cpp located in your <installdir>\examples\DayOfWeek directory.
DayOfWeekPortTypeImp::getDayOfWeek(rwsf::CallInfo& info,
const std::string& date_in)
std::string dateStr(date_in); //1
rwsf::DateTime dt(dateStr, rwsf::DateTime::setDate); // 2
// need to convert from DateTime to std::string to return to client
std::string weekDay = dt.weekDayName(); // 3
return weekDay;
//1 Copies the value string date_in containing the date provided by the client, to dateStr.
//2 Constructs an rwsf::DateTime instance dt and sets the date with the contents of dateStr.
//3 Method weekDayName() of rwsf::DateTime returns the name of the week for this date as a string, which is returned to the client.