ProLinga-Soap Project |
---|
Table of Contents
There are two types of libraries available:
Soap Library
Soap Client Library
A very basic example program using the Soap Library, so it can run as a Web Service looks like this:
#include <prolinga/Soap.hpp> int main() { PlSoapService sservice; /* Start as a web service. */ sservice.soapServiceStart("localhost", 8020, 3, 6, "/tmp/mySoap.log", 5); /* Return */ return 0; } void PlSoapLink(PlSoapProcessPtr link) { /* Every received request will access this function. */ /* Get Request */ xmlDocPtr docReq; docReq = link->getRequest(); /* Print on standard out */ xmlNodePtr curReq; xmlBufferPtr bufReq; bufReq = xmlBufferCreate(); curReq = xmlDocGetRootElement(docReq); xmlNodeDump(bufReq, docReq, curReq, 0, 1); printf("%s\n", (char *)xmlBufferContent(bufReq)); xmlBufferFree(bufReq); /* Create a response */ xmlDocPtr docRes; xmlNodePtr curRes; docRes = xmlNewDoc((const xmlChar *)"1.0"); docRes->children = xmlNewDocNode(docRes, NULL, (const xmlChar *)"ProLinga", NULL); curRes = xmlDocGetRootElement(docRes); xmlNewTextChild (curRes, NULL, (const xmlChar *)"String", (const xmlChar *)"Your request has been served."); /* Send back Response */ link->putResponse(docRes); }
When running this application, function soapServiceStart
is
called and starts an indefinite loop listening for requests to
arrive at TCP port 8020. As soon as a request arrives, function
PlSoapLink
is called with as argument
a pointer to the class
PlSoapProcess which holds the request
the request in libxml2 format. In this example the request is printed on
the console where the services has been started and a simple
XML document is sent back by assigning this to the class
PlSoapProcess.
To compile the program, use the following command:
g++ soap_s_test.cpp -o soap_s_test `pkg-config --cflags --libs prolinga-soap`
You may need to set the environment variable PKG_CONFIG_PATH to
point to the directories where prolinga-soap.pc and libxml-2.0.pc are located.
This can be directory /usr/lib
or
directory /usr/local/lib/pkgconfig
on GNU/Linux for
example.
You can also use a more traditional command as:
g++ soap_s_test.cpp -o soap_s_test -I/usr/local/include/ -L/usr/local/lib -lprolingasoap -lxml2 -lpthread -lz
<< ProLinga-Soap Project | Soap Client Library >> |