summaryrefslogtreecommitdiffstats
path: root/libcsoap
diff options
context:
space:
mode:
Diffstat (limited to 'libcsoap')
-rw-r--r--libcsoap/soap-client.c25
-rw-r--r--libcsoap/soap-client.h4
-rw-r--r--libcsoap/soap-fault.c8
-rw-r--r--libcsoap/soap-server.c50
4 files changed, 61 insertions, 26 deletions
diff --git a/libcsoap/soap-client.c b/libcsoap/soap-client.c
index b015a9c..dfb6898 100644
--- a/libcsoap/soap-client.c
+++ b/libcsoap/soap-client.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-client.c,v 1.17 2005/07/27 07:45:40 snowdrop Exp $
+* $Id: soap-client.c,v 1.18 2005/12/19 14:06:16 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -103,6 +103,9 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha
/* Transport via HTTP */
conn = httpc_new();
+ if(!conn){
+ return herror_new("soap_client_invoke", SOAP_ERROR_CLIENT_INIT, "Unable to create SOAP client!" );
+ }
conn->block = soap_client_get_blockmode();
/* Set soap action */
@@ -121,21 +124,21 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha
status = httpc_post_begin(conn, url);
if (status != H_OK) {
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
status = http_output_stream_write_string(conn->out, content);
if (status != H_OK) {
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
status = httpc_post_end(conn, &res);
if (status != H_OK) {
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
@@ -149,21 +152,21 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha
sprintf(start_id, "289247829121218%d", counter++);
status = httpc_mime_begin(conn, url, start_id, "", "text/xml");
if (status != H_OK) {
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
status = httpc_mime_next(conn, start_id, "text/xml", "binary");
if (status != H_OK) {
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
status = http_output_stream_write(conn->out, content, strlen(content));
if (status != H_OK) {
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
@@ -175,7 +178,7 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha
part->content_type, part->transfer_encoding, part->filename);
if (status != H_OK) {
log_error2("Send file failed. Status:%d", status);
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
@@ -184,7 +187,7 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha
status = httpc_mime_end(conn, &res);
if (status != H_OK)
{
- httpc_close_free(conn);
+ httpc_free(conn);
xmlBufferFree(buffer);
return status;
}
@@ -197,7 +200,7 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha
status = _soap_client_build_result(res, &res_env);
if (status != H_OK) {
hresponse_free(res);
- httpc_close_free(conn);
+ httpc_free(conn);
return status;
}
@@ -221,7 +224,7 @@ soap_client_invoke(SoapCtx *call, SoapCtx** response, const char *url, const cha
hresponse_free(res);
- httpc_close_free(conn);
+ httpc_free(conn);
return H_OK;
}
diff --git a/libcsoap/soap-client.h b/libcsoap/soap-client.h
index e0f79bf..b99d2aa 100644
--- a/libcsoap/soap-client.h
+++ b/libcsoap/soap-client.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-client.h,v 1.9 2004/11/02 23:09:26 snowdrop Exp $
+ * $Id: soap-client.h,v 1.10 2005/12/19 14:06:16 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -27,6 +27,8 @@
#include <libcsoap/soap-env.h>
#include <libcsoap/soap-ctx.h>
+#define SOAP_ERROR_CLIENT_INIT 5001
+
/**
Initializes the client side soap engine
*/
diff --git a/libcsoap/soap-fault.c b/libcsoap/soap-fault.c
index a44ad37..eeb146d 100644
--- a/libcsoap/soap-fault.c
+++ b/libcsoap/soap-fault.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-fault.c,v 1.5 2004/10/15 13:34:02 snowdrop Exp $
+* $Id: soap-fault.c,v 1.6 2005/12/19 14:06:16 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -46,12 +46,12 @@ Parameters:
" xmlns:xsi=\"%s\"" \
" xmlns:xsd=\"%s\">" \
" <SOAP-ENV:Body>"\
- " <Fault>"\
+ " <SOAP-ENV:Fault>"\
" <faultcode>%s</faultcode>"\
" <faultstring>%s</faultstring>"\
" <faultactor>%s</faultactor>"\
- " <faultdetail>%s</faultdetail>"\
- " </Fault>" \
+ " <detail>%s</detail>"\
+ " </SOAP-ENV:Fault>" \
" </SOAP-ENV:Body>"\
"</SOAP-ENV:Envelope>"
diff --git a/libcsoap/soap-server.c b/libcsoap/soap-server.c
index 8481bc3..591ecc0 100644
--- a/libcsoap/soap-server.c
+++ b/libcsoap/soap-server.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-server.c,v 1.11 2005/07/30 12:43:12 snowdrop Exp $
+* $Id: soap-server.c,v 1.12 2005/12/19 14:06:16 snowdrop Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -134,10 +134,12 @@ void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)
if (err != H_OK)
{
_soap_server_send_fault(conn, header, herror_message(err));
- if (env) soap_env_free(env);
herror_release(err);
+ return;
+ }
- } else if (env == NULL) {
+
+ if (env == NULL) {
_soap_server_send_fault(conn, header,"Can not receive POST data!");
@@ -165,14 +167,20 @@ void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)
if (!soap_env_find_urn(ctx->env, urn)) {
_soap_server_send_fault(conn, header, "No URN found!");
+ soap_ctx_free(ctx);
+ return;
} else {
log_verbose2("urn: '%s'", urn);
+ }
if (!soap_env_find_methodname(ctx->env, method)) {
_soap_server_send_fault(conn, header, "No method found!");
+ soap_ctx_free(ctx);
+ return;
}else {
log_verbose2("method: '%s'", method);
+ }
service = soap_router_find_service(router, urn, method);
@@ -180,6 +188,8 @@ void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)
sprintf(buffer, "URN '%s' not found", urn);
_soap_server_send_fault(conn, header, buffer);
+ soap_ctx_free(ctx);
+ return;
} else {
log_verbose2("func: %p", service->func);
@@ -193,30 +203,33 @@ void soap_server_entry(httpd_conn_t *conn, hrequest_t *req)
herror_message(err));
herror_release(err);
_soap_server_send_fault(conn, header, buffer);
+ soap_ctx_free(ctx);
+ return;
+ }
- } else if (ctxres->env == NULL) {
+ if (ctxres->env == NULL) {
sprintf(buffer, "Service '%s' returned no envelope", urn);
_soap_server_send_fault(conn, header, buffer);
+ soap_ctx_free(ctx);
+ return;
+
} else {
/* httpd_send_header(conn, 200, "OK");
_soap_server_send_env(conn->out, ctxres->env);
*/
_soap_server_send_ctx(conn, ctxres);
- }
/* free envctx */
soap_ctx_free(ctxres);
+ }
}
- }
- }
}
}
soap_ctx_free(ctx);
}
- hpairnode_free (header);
}
@@ -252,8 +265,26 @@ void _soap_server_send_ctx(httpd_conn_t* conn, SoapCtx *ctx)
}
else
{
- httpd_send_header(conn, 200, "OK");
+ char buflen[100];
+ xmlXPathContextPtr xpathCtx;
+ xmlXPathObjectPtr xpathObj;
+ xpathCtx = xmlXPathNewContext(ctx->env->root->doc);
+ xpathObj = xmlXPathEvalExpression("//Fault", xpathCtx);
+#ifdef WIN32
+#define snprintf(buffer, num, s1, s2) sprintf(buffer, s1,s2)
+#endif
+ snprintf(buflen,100,"%d", strlen((const char*)xmlBufferContent (buffer)));
+ httpd_set_header (conn, HEADER_CONTENT_LENGTH, buflen);
+ if((xpathObj->nodesetval) ? xpathObj->nodesetval->nodeNr : 0){
+ httpd_send_header(conn, 500, "FAILED");
+ } else {
+ httpd_send_header(conn, 200, "OK");
+ }
+
http_output_stream_write_string(conn->out, (const char*)xmlBufferContent(buffer));
+ xmlXPathFreeObject(xpathObj);
+ xmlXPathFreeContext(xpathCtx);
+
}
xmlBufferFree(buffer);
@@ -307,7 +338,6 @@ void _soap_server_send_fault(httpd_conn_t *conn, hpair_t *header,
herror_release(err);
} else {
_soap_server_send_env(conn->out, envres);
- soap_env_free(envres);
}
}