![]() |
Table of Contents
gSOAP for CCreate the Stubs
Using wsdl2h -c -oWSDbfetchService "http://www.ebi.ac.uk/ws/services/WSDbfetch?wsdl"
Process the generated header file ( soapcpp2 -c -pWSDbfetch -C WSDbfetchService.h
Again the Client Code
Now we have stubs, we need to write some code that uses them, for example ( /* Include generated stubs */ #include "WSDbfetchH.h" #include "WSDbfetchSoapBinding.nsmap" main() { /* Arguments for query */ char *query = "UNIPROT:WAP_RAT"; char *format = "fasta"; char *style = "raw"; /* For the result */ char *result = NULL; /* Create a service proxy */ struct soap *soap = soap_new(); /* Make the request, checking for failure */ if(soap_call_ns1__fetchData(soap, NULL, NULL, query, format, style, &result) == SOAP_OK) { /* Print the result */ printf("%s", result); } else { /* An error occurred, so print the message. */ soap_print_fault(soap, stderr); } /* Clean-up the proxy */ soap_end(soap); soap_free(soap); } Compile the ClientCompiling the C source and linking to create an executable: cc -o wsdbfetch_gsoap_c WSDbfetchC.c WSDbfetchClient.c wsdbfetch_gsoap_c.c -lgsoap Complex Types
Complex types, such as the data structures used to pass the parameters and data to the /* Create a service proxy */ struct soap *soap = soap_new(); /* Populate parameters */ struct ns1__inputParams params; params.email = "your@email"; enum xsd__boolean asyncVal = xsd__boolean__true_; params.async = &asyncVal; params.program = "blastp"; params.database = "swissprot"; params.matrix = NULL; params.exp = NULL; params.echofilter = NULL; params.filter = NULL; params.numal = NULL; params.scores = NULL; params.sensitivity = NULL; params.sort = NULL; params.stats = NULL; params.strand = NULL; params.outformat = NULL; params.topcombon = NULL; params.appxml = NULL; /* Populate data */ struct WSArrayofData* data = (struct WSArrayofData*)soap_malloc(soap, sizeof(struct WSArrayofData)); data->__size = 1; data->__ptr = (struct ns1__data**)soap_malloc(soap, sizeof(struct ns1__data*) * data->__size); data->__ptr[0] = (struct ns1__data*)soap_malloc(soap, sizeof(struct ns1__data) ); data->__ptr[0]->type = "sequence"; data->__ptr[0]->content = "uniprot:slpi_human"; /* Submit job */ char *jobId = NULL; if(soap_call_ns1__runWUBlast(soap, NULL, NULL, ¶ms, data, &jobId) != SOAP_OK) { /* An error occured, so print the message. */ soap_print_fault(soap, stderr); exitStatus = 1; } /* Print job identifier */ printf("%s\n", jobId); ExamplesComplete source code for the examples are available: ![]() |