diff --git a/src/client.c b/src/client.c index 51a360d5427aaa2e4e458e7d9146104926d3e3b1..21c67c0a871ac99ef42bcc7a6f614e863ef56ea2 100644 --- a/src/client.c +++ b/src/client.c @@ -298,3 +298,47 @@ char *read_xml_file(char *basedir) fclose(xmlFile); return xmlInventory; } + +/*---------------------------------------------------------------------------- + * Summary: Contact webservice server, sending the collected XML data. + * Parameters: + * soap SOAP struct + * url URL of the contacted webservice server + * basedir String with basedir path + * Return: void + */ +void inventory(struct soap *soap, char *url, char *basedir) +{ + char *invResult, *xmlInventory; + + xmlInventory = read_xml_file(basedir); + + if (soap_call_ns1__setInventory(soap, url, "", xmlInventory, &invResult) + != SOAP_OK) + { + soap_print_fault(soap, stderr); + exit(2); + } + + /* Get inventory result from response */ + if (DEBUG) + { + printf("InvResult: %s\n", invResult); + } + + /* Verify response and print appropriate message */ + if (strcmp(invResult, "Success") == 0) + { + fprintf(stdout, "XML data sent successful\n"); + } + else if (strcmp(invResult, "Error") == 0) + { + fprintf(stdout, "XML data sent error\n"); + exit(5); + } + else + { + fprintf(stdout, "%s\nUnexpected result from server\n", invResult); + exit(6); + } +}