Library
This chapter describes the built-in callback functions and data conversion library provided for web service consumer functions.
1. Callback Function
The gateway execution file is provided for web service consumer functions. In order to convert Tmax messages to SOAP messages, the gateway execution file must be created and executed by implementing and building the provided callback function and WSGW library, libwsgw. For preprocessing before sending or receiving messages from the gateway, the library and the callback functions must be implemented and built into a wsgw file.
The following are the callback functions provided by the library.
Function | Description |
---|---|
Callback function in WebService gateway. Request is made from Tmax to a remote server. |
|
Called when Tmax sends a reply to a remote server. |
|
Called when a remote server sends a request to Tmax. |
|
Called when a remote server sends a reply to Tmax. |
1.1. *request_from_tmax
This callback function is called when Tmax sends a request to a remote server.
-
Prototype
int (*request_from_tmax)(char *tmaxmsg, int ilen, char **soapmsg, int *olen, char **service, char **uri, char **soap_version);
-
Parameter
Parameter Description tmaxmsg [in]
Tmax message to convert
ilen [in]
Length of the Tmax message (tmaxmsg).
soapmsg [out]
Converted SOAP message. It must be allocated using malloc as it will be set free internally.
olen [out]
Length of the converted SOAP message.
service [out]
Actual service name. It must be allocated through malloc as it will be set free internally.
uri [out]
Uri. It must be allocated through malloc as it will be set free internally.
soap_version [out]
SOAP version (1.1 or 1.2). It must be allocated through malloc as it will be set free internally.
1.2. *reply_from_tmax
This callback function is called when tmax sends a reply to a remote server.
-
Prototype
int (*reply_from_tmax)(char *tmaxmsg, char **soapmsg, int *olen, char **service);
-
Parameter
Parameter Description tmaxmsg [in]
Tmax message to convert.
soapmsg [out]
Converted SOAP message.
olen [out]
Length of the converted SOAP message.
service [out]
Actual service name.
1.3. *request_from_remote
This callback function is called when a remote server sends a request to tmax.
-
Prototype
int (*request_from_remote)(char *soapmsg, int soapmsglen, char **tmaxmsg, char **service);
-
Parameter
Parameter Description soapmsg [in]
SOAP message to convert.
soapmsglen [in]
Length of the SOAP message (soapmsg).
tmaxmsg [out]
Converted Tmax message.
service [out]
Actual service name.
1.4. *reply_from_remote
This callback function is called when a remote server sends a reply to tmax.
-
Prototype
int (*reply_from_remote)(char *soapmsg, int soapmsglen, char **tmaxmsg, int *olen);
-
Parameter
Parameter Description soapmsg [in]
SOAP message to convert.
soapmsglen [in]
Length of the SOAP message (soapmsg).
tmaxmsg [out]
Converted Tmax message.
olen [out]
Length of the Tmax message (tmaxmsg).
Example
The following is an example code.
#include <usrinc/wsgw_user.h> int main(int argc, char *argv[]) { request_from_tmax = NULL; reply_from_tmax = NULL; request_from_remote = NULL; reply_from_remote = NULL; return wsgw_main(argc,argv); }
2. Data Conversion Library
The data conversion library, libwsgw, is used to convert Tmax messages and SOAP messages. In WebService gateway, the Tmax buffer is automatically converted to SOAP messages according to the specified rule. This library is used when the user wants to arbitrarily perform the conversion in svrlib.
The following table is the list of functions provided by the library.
Function | Description |
---|---|
Sets environment configuration. |
|
Converts Tmax messages (tmaxmsg) to SOAP messages (soapmsg). |
|
Converts SOAP messages (soapmsg) to Tmax messages (tmaxmsg). |
2.1. init_config
This function sets the environment configuration.
-
Prototype
int init_config(char *configfile, char *metafile);
-
Parameter
Parameter Description configfile [in]
Web service environment configuration file path.
metafile [in]
Web service information file path.
2.2. convert_tmax_to_soap
This function converts Tmax messages (tmaxmsg) to SOAP messages (soapmsg).
-
Prototype
int convert_tmax_to_soap(char *svcname, char *tmaxmsg, char **soapmsg, int *olen, char *subtype, char *uri, char *soapversion, char *encodingstyle, char *wsns, char *typens );
-
Parameter
Parameter Description svcname [in]
Service name.
tmaxmsg [in]
Tmax message to convert.
soapmsg [out]
Allocates memory within the function.
olen [out]
SOAP message (soapmsg) length.
subtype [in]
Struct name of the Tmax message (tmaxmsg).
uri [in]
URL of the web service provider.
soapversion [in]
Version (1.1 or 1.2) of the SOAP message (soapmg).
encodingstyle [in]
Encoding type (rpc or doc) of the SOAP message (soapmsg).
wsns [in]
Namespace of the SOAP message (soapmsg).
typens [in]
Namespace of the SOAP message (soapmsg) type.
2.3. convert_soap_to_tmax
This function converts SOAP messages (soapmsg) to Tmax messages (tmaxmsg).
-
Prototype
int convert_soap_to_tmax(char *soapmsg, int soapmsglen, char **tmaxmsg, int *len);
-
Parameter
Parameter Description soapmsg [in]
SOAP message to convert.
soapmsglen [in]
Length of the SOAP message (soapmsg).
tmaxmsg [out]
Memory alloc in the function.
len [out]
Length of the Tmax message (tmaxmsg).