Using the Named Object
If you have done everything as described in the previous sections, an object named MyString should be registered in the HydraExpress Agent global naming context. Here is how you would use it in your server implementation code:
 
std::string DayOfWeekPortTypeImp::getDayOfWeek(rwsf::CallInfo& callInfo,
const std::string& date_in)
{
rwsf::NamingContext* c =
rwsf::NamingContext::getGlobalInstance(); //1
rwsf::NamedObject obj = c->lookup("MyString"); //2
MyString *str; //3
rwsf::naming_extract<MyString>(obj,str); //4
return std::string(str->getStr()); //5
}
//1 Gets an instance of the global naming context.
//2 Looks up the object MyString in the global context.
//3 Creates an instance of MyString.
//4 Calls the global template function rwsf::naming_extract<>() to serialize the named object value to the MyString type.
//5 Returns the string “It might be Wednesday” to the client for the DayOfWeek example. The response, of course, no longer has any relationship to the input date value.
For descriptions of the classes rwsf::NamingContext and rwsf::NamedObject, see the HydraExpress C++ API Reference Guide.