1/* 2 ckdbtest.c 3 4 Test client for HTTP cookie database manager. 5 6 Copyright (C) 2000-2002 Robert A. van Engelen. All Rights Reserved. 7 81. Compile ckdb.h: 9 soapcpp2 -cnpckdb ckdb.h 102. Compile ckdb.c: 11 gcc -DWITH_COOKIES -c ckdb.c 123. Compile and link ckdbtest.c: 13 soapcpp2 -c ckdbtest.h 14 gcc -DWITH_COOKIES ckdbtest.c ckdb.o stdsoap2.c soapC.c soapClient.c 154. Execute 16 Cookies will be stored in 'jar.xml' 17 18*/ 19 20#include "soapH.h" 21#include "ckdbtest.nsmap" 22 23char ckserver[] = "http://www.cs.fsu.edu/~engelen/ck.cgi"; 24 25int main() 26{ struct soap soap; 27 char *r; 28 soap_init(&soap); 29 if (soap_call_ck__demo(&soap, ckserver, NULL, &r)) 30 { soap_print_fault(&soap, stderr); 31 soap_print_fault_location(&soap, stderr); 32 exit(-1); 33 } 34 printf("The server responded with: %s\n", r); 35 if (soap_save_cookies(&soap, "jar.xml")) 36 fprintf(stderr, "Cannot store cookies\n"); 37 soap_free_cookies(&soap); 38 if (soap_load_cookies(&soap, "jar.xml")) 39 fprintf(stderr, "Cannot restore cookies\n"); 40 else 41 printf("Got cookies (%s=%s)\n", soap.cookies->name, soap.cookies->value); 42 if (soap_call_ck__demo(&soap, ckserver, NULL, &r)) 43 { soap_print_fault(&soap, stderr); 44 soap_print_fault_location(&soap, stderr); 45 exit(-1); 46 } 47 printf("The server responded with: %s\n", r); 48 if (soap_save_cookies(&soap, "jar.xml")) 49 fprintf(stderr, "Cannot store cookies\n"); 50 soap_end(&soap); /* This will delete the deserialized cookies too! */ 51 soap.cookies = NULL; /* so make sure this is NULL */ 52 return 0; 53} 54