HydraExpress Components : Web Service Development Guide : PART I Getting Started : Working with Data : Complex Data : Working with the Generated Data Classes in the Client and Server Implementations
Working with the Generated Data Classes in the Client and Server Implementations
Let’s take a look at the service operation method in the generated client implementation, WeatherSummaryClient.cpp:
void invoke_weatherUpdate(WeatherSummaryProxy& proxy)
wsx::WeatherSummary weatherData_in;
rwsf::CallInfo callInfo;
Note that the generated code simply creates an instance of the datatype class WeatherSummary. The provided client implementation instantiates a WeatherSummary object, then uses the generated mutators to set a value on each simple type contained in the object:
wsx::WeatherSummary ws;
The server-side implementation simply calls the weatherNotification notification-style service (See Chapter 9 for an explanation of the notification message pattern) with the WeatherSummary object. We can look at the weatherNotification operation to understand how to work with the data in WeatherSummary. Here's the generated server implementation:
virtual void weatherNotification(rwsf::CallInfo& info,
const wsx::WeatherSummary& weatherData_in);
The provided notification implementation WeatherSummaryNotificationImp.cpp uses the generated accessors to retrieve each simple type’s value:
WeatherSummaryNotificationImp::weatherNotification(rwsf::CallInfo& callInfo,
const wsx::WeatherSummary& weatherData_in)
std::cout << "WEATHER UPDATE RECEIVED: " << std::endl
<< " zipcode = " << weatherData_in.getZipcode() << std::endl
<< " windSpeed = " << weatherData_in.getWindSpeed() << std::endl
<< " sky = " << weatherData_in.getSky() << std::endl
<< " temp = " << weatherData_in.getTemp() << std::endl
<< std::endl;