mod_gsoap @ Apache

1. download mod_gsoap, make sure Apache installed.

2. update httpd.conf.

LoadModule gsoap_module libexec/mod_gsoap.so SetHandler gsoap-handler #SOAPLibrary /home/myusername/gsoap.0.0.5/apache/example/calculator/.libs/libCalculator.so  

3. ///////////////////////////////calc.h //gsoap ns service name: calc //gsoap ns schema namespace: urn:calc int ns__add(double a, double b, double *result); ///////////////////////////////mod_calc.c #include #include "soapH.h" /* get the gSOAP-generated definitions */ #include "calc.nsmap" /* get the gSOAP-generated namespace bindings */ #include "apache_gsoap.h" IMPLEMENT_GSOAP_SERVER() int ns__add(struct soap *soap, double a, double b, double *result){ *result = a + b; return SOAP_OK; } ////////////////////////////////client.c #include #include "soapH.h" #include "calc.nsmap" int main (int argc, char *argv[]) { struct soap *soap = soap_new(); /* create environnement */ double n; /* result value */ if ( soap_call_ns__add (soap, "http://ip/soap", NULL, atoi(argv[1]), atoi (argv[2]), &n ) == SOAP_OK ) printf("%d plus %d fait %f/n", atoi(argv[1]), atoi (argv[2]), n); else soap_print_fault(soap, stderr); /* print error */ soap_end(soap); /* clean up deserialized data */ soap_done(soap); /* detach environment */ free(soap); return (0); } 

4. ############################Makefile all: soapcpp2 -c calc.h gcc -fPIC -I/usr/apache2/include/ -I../../mod_gsoap/mod_gsoap-0.6/apache_20/ -shared -o mod_cal.so mod_calc.c soapC.c soapServer.c stdsoap2.c -lsocket -lnsl gcc -g -o client client.c soapC.c soapClient.c stdsoap2.c -lsocket -lnsl 

 

你可能感兴趣的:(soap,apache,struct,download,schema,gcc)