Edit the Server-Side Code to Return a Response Based on the Header
On the server-side, the server code extracts the locale information from the SOAP header and uses it to create an appropriate response for the locale.
Open the generated server sample implementation GreetingPortTypeImp.cpp located in your Extended\app\server directory. Let’s look at the generated sample service operation method:
 
std::string
GreetingPortTypeImp::sayHello(rwsf::CallInfo& callInfo, const std::string&
hellorequest_in)
{
typedef std::string returnType;
throw rwsf::ServerFault("Sorry: The service was invoked but the requested
operation \"sayHello\" has not been implemented. An implementation must be
written.");
return returnType(); // (never executed)
}
 
To implement the method to extract the locale information from the client’s SOAP header, replace the code above with the implementation below:
 
std::string GreetingPortTypeImp::sayHello(rwsf::CallInfo& callInfo,
const std::string& hellorequest_in)
{
std::string localeValue = //1
callInfo.getRequestSoapHeaderValue(
rwsf::XmlName("LocaleHeader", rwsf::XmlNamespace("locale",
"http://www.roguewave.com/examples/webservices/helloworld")));
std::string response;
if (localeValue == "es_MX") { //2
response = "Hola al mundo!";
}
else {
response = "Hello" + hellorequest_in;
}
return std::string(response); //3
}
//1 Extracts the value for the locale contained in the SOAP header from the client.
//2 Logic to determine the correct response. Of course, a real application would have some kind of map from locale value to appropriate responses.
//3 Returns the appropriate response.
Save and close the file.