Web Service Development Guide : PART I Getting Started : Chapter 6 Working with Data : Simple Data
Simple Data
WSDL messages may contain zero or any number of parts. Each part defines a single object and its type, either simple or complex. This section considers messages that contain zero, single, or multiple parts representing simple data.
Messages with No Parts
The simplest message contains no parts. This can be achieved using a WSDL message defined with no part elements as children:
 
<message name="VoidRequest">
</message>
This style of messaging is useful to execute a web service as a function with no data, like a void method in C++. It can also be used in a response, as a notification of completion. Otherwise, its use is fairly limited compared to the other styles, as it conveys no runtime data.
The generated client and server implementation will look just like functions for messages with parts (see below) except the arguments for the message parameters will be absent:
 
void
MyPortTypeImp::func(rwsf::CallInfo& callInfo)
{
...
}
Messages with a Single Part
For messages that contain runtime data, the simplest type contains just one part that includes a simple type.
Consider the following WSDL file excerpt, taken from the HelloWorld example:
 
<message name="HelloRequest">
<part name="hellorequest" type="xsd:string"/>
</message>
<message name="HelloResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="GreetingPortType">
<operation name="sayHello">
<input message="tns:HelloRequest" />
<output message="tns:HelloResponse" />
</operation>
</portType>
The input and output messages each include a single part containing a string.
The generated service operation method in the client implementation GreetingPortClient.cpp creates a simple string to represent the input and output values, like so:
 
void invoke_sayHello(GreetingBindingProxy& proxy)
{
std::string hellorequest_in;
std::string return_ret;
rwsf::CallInfo callInfo;
On the server side, the generated code is equally simple, providing the string as an argument to the service operation method:
 
std::string
GreetingPortTypeImp::sayHello(rwsf::CallInfo& callInfo,
const std::string& hellorequest_in)
{
...
}
Messages with Multiple Parts
Messages may contain multiple parts. Here is an excerpt from the WeatherSummary example’s WSDL file. Each message contains multiple parts that define simple-type data:
 
<message name="subscribe">
<part name="host" type="xsd:string"/>
<part name="port" type="xsd:string"/>
<part name="transportName" type="xsd:string"/>
</message>
 
<message name="subscribeResponse">
<part name="status" type="xsd:boolean"/>
<part name="message" type="xsd:string"/>
</message>
In this case, the generated service operation methods simply instantiate multiple simple-type objects representing the input and output parameters to the operation, and then pass them to the proxy. On the client side, the generated service operation method in WeatherSummaryClient.cpp looks like this:
 
void invoke_subscribe(WeatherSummaryProxy& proxy)
{
std::string host_in;
std::string port_in;
std::string transportName_in;
bool status_out;
std::string message_out;
rwsf::CallInfo callInfo;
...
proxy.subscribe(callInfo, host_in,
port_in, transportName_in,
status_out, message_out);
}
 
Likewise, on the server side, the signature of the generated code’s service operation method takes these input and output messages as its parameters:
 
void
WeatherSummaryImp::subscribe(rwsf::CallInfo& callInfo,
const std::string& host_in,
const std::string& port_in,
const std::string& transportName_in,
bool& status_out,
std::string& message_out)
{
...
}
 
Note that the return type is the part type when the response message has one part, and void when the response message has multiple parts. In this case, the response parts are given as reference parameters. All parameters have _in or _out appended to their names to signify whether they represent request or response parts.