added IF-MAP SOAP error handling
This commit is contained in:
@@ -51,8 +51,8 @@ struct private_tnc_ifmap2_soap_msg_t {
|
|||||||
/**
|
/**
|
||||||
* Send HTTP POST request and receive HTTP response
|
* Send HTTP POST request and receive HTTP response
|
||||||
*/
|
*/
|
||||||
static bool http_send_receive(private_tnc_ifmap2_soap_msg_t *this,
|
static bool http_post(private_tnc_ifmap2_soap_msg_t *this, chunk_t out,
|
||||||
chunk_t out, chunk_t *in)
|
chunk_t *in)
|
||||||
{
|
{
|
||||||
char header[] =
|
char header[] =
|
||||||
"POST /ifmap HTTP/1.1\r\n"
|
"POST /ifmap HTTP/1.1\r\n"
|
||||||
@@ -150,9 +150,9 @@ METHOD(tnc_ifmap2_soap_msg_t, post, bool,
|
|||||||
char *result_name, xmlNodePtr *result)
|
char *result_name, xmlNodePtr *result)
|
||||||
{
|
{
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlNodePtr env, body, cur;
|
xmlNodePtr env, body, cur, response;
|
||||||
xmlNsPtr ns;
|
xmlNsPtr ns;
|
||||||
xmlChar *xml;
|
xmlChar *xml, *errorCode, *errorString;
|
||||||
int len;
|
int len;
|
||||||
chunk_t in, out;
|
chunk_t in, out;
|
||||||
|
|
||||||
@@ -176,8 +176,8 @@ METHOD(tnc_ifmap2_soap_msg_t, post, bool,
|
|||||||
DBG3(DBG_TNC, "%.*s", len, xml);
|
DBG3(DBG_TNC, "%.*s", len, xml);
|
||||||
out = chunk_create(xml, len);
|
out = chunk_create(xml, len);
|
||||||
|
|
||||||
/* Send SOAP-XML request via HTTP */
|
/* Send SOAP-XML request via HTTP POST */
|
||||||
if (!http_send_receive(this, out, &in))
|
if (!http_post(this, out, &in))
|
||||||
{
|
{
|
||||||
xmlFree(xml);
|
xmlFree(xml);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -217,16 +217,39 @@ METHOD(tnc_ifmap2_soap_msg_t, post, bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get IF-MAP response */
|
/* get IF-MAP response */
|
||||||
cur = find_child(cur, "response");
|
response = find_child(cur, "response");
|
||||||
if (!cur)
|
if (!response)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get IF-MAP result */
|
/* get IF-MAP result */
|
||||||
cur = find_child(cur, result_name);
|
cur = find_child(response, result_name);
|
||||||
if (!cur)
|
if (!cur)
|
||||||
{
|
{
|
||||||
|
cur = find_child(response, "errorResult");
|
||||||
|
if (cur)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, "received errorResult");
|
||||||
|
|
||||||
|
errorCode = xmlGetProp(cur, "errorCode");
|
||||||
|
if (errorCode)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, " %s", errorCode);
|
||||||
|
xmlFree(errorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
cur = find_child(cur, "errorString");
|
||||||
|
if (cur)
|
||||||
|
{
|
||||||
|
errorString = xmlNodeGetContent(cur);
|
||||||
|
if (errorString)
|
||||||
|
{
|
||||||
|
DBG1(DBG_TNC, " %s", errorString);
|
||||||
|
xmlFree(errorString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user