![]() |
Table of Contents
gSOAP for C++Create the Stubs
Using wsdl2h -oWSDbfetchService "http://www.ebi.ac.uk/ws/services/WSDbfetch?wsdl"
Process the generated header file ( soapcpp2 -i -I/usr/include/gsoap -pWSDbfetch -C WSDbfetchService.h
Using Client Code
Now we have stubs, we need to write some code that uses them, for example ( // Include generated stubs #include "WSDbfetchWSDbfetchSoapBindingProxy.h" #include "WSDbfetchSoapBinding.nsmap" int main(int argc, char* argv[]) { // Exit status to return int exitStatus = 0; // Arguments for query std::string query = "UNIPROT:WAP_RAT"; std::string format = "fasta"; std::string style = "raw"; // For the result std::string result; // Service proxy WSDbfetchSoapBindingProxy srvProxy; // Make the request, checking for failure if (srvProxy.fetchData(query, format, style, result) == SOAP_OK) { // Print the result std::cout << result << std::endl; } else { // An error occured, so print the message. std::cerr << srvProxy.soap_fault_string() << std::endl; exitStatus = 1; } return exitStatus; } Compile the ClientCompiling the C++ source and linking to create an executable: cxx -o wsdbfetch_gsoap_cpp WSDbfetchC.cpp WSDbfetchWSDbfetchSoapBindingProxy.cpp wsdbfetch_gsoap_cpp.cpp -lgsoap++ Complex Types
Complex types, such as the data structures used to pass the parameters and data to the // Populate parameters ns1__inputParams params; params.email = "your@email"; bool async = true; params.async = &async; params.program = "blastp"; params.database = "swissprot"; // Populate data ns1__data content; content.type = "sequence"; content.content = "uniprot:slpi_human"; ns1__data *contentArray = new ns1__data[1]; contentArray[0] = content; WSArrayofData data; data.__ptr = &contentArray; data.__size = 1; // Service proxy WSWUBlastSoapBindingProxy srvProxy; // Submit job std::string jobId; if (srvProxy.runWUBlast(¶ms, &data, jobId) != SOAP_OK) { // An error occured, so print the message. std::cerr << srvProxy.soap_fault_string() << std::endl; exitStatus = 1; return exitStatus; } // Print the job identifier std::cout << jobId << std::endl; ExamplesComplete source code for the examples are available: ![]() |