Download gSOAP 2.7.0 User Guide

Transcript
8.1.15
How to Specify a Method with No Output Parameters
To specify a remote method that has no output parameters, just provide a function prototype with
a response struct that is empty. For example:
enum ns event { off, on, stand by };
int ns signal(enum ns event in, struct ns signalResponse { } *out);
Since the response struct is empty, no output parameters are specified. Most C/C++ compilers
allow empty structs. For those that don’t, use a void* parameter in the struct. This parameter is
not (de)serialized.
Some SOAP resources refer to SOAP RPC with empty responses as one way SOAP messaging.
However, we refer to one-way massaging by asynchronous explicit send and receive operations as
described in Section 8.3. We found this view of one-way SOAP messaging more useful by providing
a message passing alternative to SOAP RPC.
8.2
How to Use the gSOAP Stub and Skeleton Compiler to Build SOAP Web
Services
The gSOAP stub and skeleton compiler generates skeleton routines in C++ source form for each
of the remote methods specified as function prototypes in the header file processed by the gSOAP
compiler. The skeleton routines can be readily used to implement the remote methods in a new
SOAP Web service. The compound data types used by the input and output parameters of SOAP
remote methods must be declared in the header file, such as structs, classes, arrays, and pointerbased data structures (graphs) that are used as the data types of the parameters of a remote method.
The gSOAP compiler automatically generates serializers and deserializers for the data types to
enable the generated skeleton routines to encode and decode the contents of the parameters of the
remote methods. The gSOAP compiler also generates a remote method request dispatcher routine
that will serve requests by calling the appropriate skeleton when the SOAP service application is
installed as a CGI application on a Web server.
8.2.1
Example
The following example specifies three remote methods to be implemented by a new SOAP Web
service:
// Contents of file ”calc.h”:
typedef double xsd double;
int ns add(xsd double a, xsd double b, xsd double &result);
int ns sub(xsd double a, xsd double b, xsd double &result);
int ns sqrt(xsd double a, xsd double &result);
The add and sub methods are intended to add and subtract two double floating point numbers
stored in input parameters a and b and should return the result of the operation in the result output
parameter. The qsrt method is intended to take the square root of input parameter a and to return
the result in the output parameter result. The xsd double type is recognized by the gSOAP compiler
30