summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar m0gg2007-01-01 18:58:05 +0000
committerGravatar m0gg2007-01-01 18:58:05 +0000
commit23629635c0d544c4fbbc0bd5d01dd75413942a3f (patch)
tree1a4dfb3e289e05f5eea6daff090a69a03ee9f122
parentfbfd56fb7c1ce480d15682652d9c5f43aa16e0b1 (diff)
downloadcsoap-23629635c0d544c4fbbc0bd5d01dd75413942a3f.tar.gz
csoap-23629635c0d544c4fbbc0bd5d01dd75413942a3f.tar.bz2
WSDL via HTTP GET re-enabled
-rw-r--r--TODO5
-rw-r--r--examples/csoap/simpleserver.c8
-rw-r--r--libcsoap/soap-nhttp.c30
-rw-r--r--libcsoap/soap-server.h33
-rw-r--r--nanohttp/nanohttp-client.h8
-rwxr-xr-xnanohttp/nanohttp-mime.h46
-rw-r--r--nanohttp/nanohttp-server.h43
7 files changed, 139 insertions, 34 deletions
diff --git a/TODO b/TODO
index e51af47..0e1933d 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.14 2007/01/01 15:29:48 m0gg Exp $
+$Id: TODO,v 1.15 2007/01/01 18:58:05 m0gg Exp $
===============================================================================
Things to do _before_ 1.2 release:
@@ -19,9 +19,6 @@ nanohttp:
csoap:
------
-- Map corrent HTTP status codes in soap_server_process (404, 500, etc.)
-- Re-enable WSDL via HTTP GET
- - move service description documents from router to service (???)
- Check portability to Win32/Linux/MaxOS (only tested on FreeBSD 6.2)
- Improve API documentation
- Add reference to http://www.w3.org/TR/SOAP-attachments
diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c
index 6439a65..0bd7341 100644
--- a/examples/csoap/simpleserver.c
+++ b/examples/csoap/simpleserver.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleserver.c,v 1.28 2006/12/10 19:21:05 m0gg Exp $
+ * $Id: simpleserver.c,v 1.29 2007/01/01 18:58:05 m0gg Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -44,7 +44,7 @@ herror_t
say_hello(struct SoapCtx *req, struct SoapCtx *res)
{
herror_t err;
- char *name;
+ xmlChar *name;
xmlNodePtr method, node;
printf("processing service request\n");
@@ -70,11 +70,11 @@ say_hello(struct SoapCtx *req, struct SoapCtx *res)
node = soap_xml_get_children(method);
while (node)
{
- name = (char *) xmlNodeListGetString(node->doc, node->xmlChildrenNode, 1);
+ name = xmlNodeListGetString(node->doc, node->xmlChildrenNode, 1);
soap_env_add_itemf(res->env, "xsd:string", "echo", "Hello '%s'", name);
- node = soap_xml_get_next(node);
if (name)
xmlFree(name);
+ node = soap_xml_get_next(node);
}
printf("service request done\n");
diff --git a/libcsoap/soap-nhttp.c b/libcsoap/soap-nhttp.c
index d43de46..833b78f 100644
--- a/libcsoap/soap-nhttp.c
+++ b/libcsoap/soap-nhttp.c
@@ -1,5 +1,5 @@
/******************************************************************
-* $Id: soap-nhttp.c,v 1.11 2006/12/16 16:09:45 m0gg Exp $
+* $Id: soap-nhttp.c,v 1.12 2007/01/01 18:58:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -59,6 +59,8 @@
#include "soap-transport.h"
#include "soap-addressing.h"
#include "soap-xml.h"
+#include "soap-router.h"
+#include "soap-server.h"
#include "soap-admin.h"
#include "soap-wsil.h"
@@ -146,25 +148,21 @@ soap_nhttp_process(httpd_conn_t * conn, struct hrequest_t * req)
struct SoapCtx *response;
herror_t err;
- /* if (req->method == HTTP_REQUEST_GET && router->wsdl)
+ if (req->method == HTTP_REQUEST_GET)
{
- _soap_nhttp_send_document(conn, router->wsdl);
- return;
- } */
+ struct SoapRouter *router;
+
+ router = soap_server_find_router(req->path);
+ if (router && router->description)
+ {
+ _soap_nhttp_send_document(conn, router->description);
+ return;
+ }
+ }
if (req->method != HTTP_REQUEST_POST)
{
- httpd_send_header(conn, 200, HTTP_STATUS_200_REASON_PHRASE);
- http_output_stream_write_string(conn->out,
- "<html>"
- "<head>"
- "</head>"
- "<body>"
- "<h1>Sorry!</h1>"
- "<hr />"
- "<div>I only speak with 'POST' method.</div>"
- "</body>"
- "</html>");
+ httpd_send_not_implemented(conn, "I only speak with 'POST' method.");
return;
}
diff --git a/libcsoap/soap-server.h b/libcsoap/soap-server.h
index 2b3d9c0..359458d 100644
--- a/libcsoap/soap-server.h
+++ b/libcsoap/soap-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: soap-server.h,v 1.24 2006/12/13 08:18:53 m0gg Exp $
+ * $Id: soap-server.h,v 1.25 2007/01/01 18:58:05 m0gg Exp $
*
* CSOAP Project: A SOAP client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -113,7 +113,22 @@
/** @page csoap_page cSOAP
*
- * T.B.D.
+ * @section csoap_sec cSOAP
+ *
+ * cSOAP is a C-based implementation of the Simple Object Access Protocol (SOAP)
+ * version 1.1.
+ *
+ * SOAP is a lightweight protocol for exchange of information in a decentralized,
+ * distributed environment. It is an XML based protocol that consists of three
+ * parts:
+ * - an envelope that defines a framework for describing what is in a message and
+ * how to process it,
+ * - a set of encoding rules for expressing instances of application-defined
+ * datatypes,
+ * - and a convention for representing remote procedure calls and responses.
+ * SOAP can potentially be used in combination with a variety of other protocols;
+ * however, the only bindings defined in this document describe how to use SOAP
+ * in combination with HTTP and HTTP Extension Framework.
*
* @section soap_howto_sec HOWTOs and coding examples
*
@@ -121,6 +136,16 @@
* - @subpage csoap_server_page
* - @subpage csoap_mime_page
*
+ * @version 1.2
+ *
+ * @author Ferhat Ayaz
+ * @author Michael Rans
+ * @author Matt Campbell
+ * @author Heiko Ronsdorf
+ *
+ * @see http://www.w3.org/TR/soap/
+ * @see http://www.w3.org/TR/2000/NOTE-SOAP-20000508/
+ *
*/
/** @page csoap_server_page Howto write a SOAP server
@@ -137,6 +162,10 @@
* @section soap_server_init_sec Server initialization
*
* @code
+ * static const char const *url = "/csoapserver";
+ * static const char const *urn = "urn:examples";
+ * static const char const *method = "sayHello";
+ *
* int main(int argc, char **argv)
* {
* herror_t err;
diff --git a/nanohttp/nanohttp-client.h b/nanohttp/nanohttp-client.h
index 9c72fe1..d993c34 100644
--- a/nanohttp/nanohttp-client.h
+++ b/nanohttp/nanohttp-client.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-client.h,v 1.37 2006/12/13 08:26:01 m0gg Exp $
+ * $Id: nanohttp-client.h,v 1.38 2007/01/01 18:58:05 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -375,6 +375,12 @@ extern herror_t httpc_post_end(httpc_conn_t * conn, hresponse_t ** out);
/**
*
+ * @todo move to nanohttp-mime.c merge with httpc_mime_* functions
+ *
+ */
+
+/**
+ *
* Begin MIME multipart/related POST request
*
* @return H_OK on success or error flag
diff --git a/nanohttp/nanohttp-mime.h b/nanohttp/nanohttp-mime.h
index 6ea0ef8..0edc5ca 100755
--- a/nanohttp/nanohttp-mime.h
+++ b/nanohttp/nanohttp-mime.h
@@ -3,7 +3,7 @@
* | \/ | | | | \/ | | _/
* |_''_| |_| |_''_| |_'/ PARSER
*
-* $Id: nanohttp-mime.h,v 1.14 2006/12/09 09:27:11 m0gg Exp $
+* $Id: nanohttp-mime.h,v 1.15 2007/01/01 18:58:05 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -28,10 +28,50 @@
#ifndef __nanohttp_mime_h
#define __nanohttp_mime_h
-/** @file
+/** @page nanohttp_mime_page nanoHTTP MIME attachments
+ *
+ * @section Table of contents
+ *
+ * - @ref nanohttp_mime_client_sec
+ * - @ref nanohttp_mime_client_init_sec
+ * - @ref nanohttp_mime_client_request_sec
+ * - @ref nanohttp_mime_client_response_sec
+ * - @ref nanohttp_mime_client_cleanup_sec
+ * - @ref nanohttp_mime_server_sec
+ * - @ref nanohttp_mime_server_init_sec
+ * - @ref nanohttp_mime_server_cleanup_sec
+ *
+ * @section nanohttp_mime_client_sec nanoHTTP client with MIME attachments
+ *
+ * @subsection nanohttp_mime_client_init_sec Client initialization
+ *
+ * See @ref nanohttp_client_init_sec for more information about client
+ * initialization.
+ *
+ * @subsection nanohttp_mime_client_request_sec Request the server
+ *
+ * The following functions can be used to transmit MIME attachments:
+ *
+ * @code
+ * httpc_mime_begin(conn, url, start_id, "", "text/tml")
+ * httpc_mime_next(conn, start_id, "text/xml", "binary")
+ * http_output_stream_write(conn->out, buffer, size)
+ * http_mime_send_file()
+ * http_mime_end(conn, &res)
+ * @endcode
+ *
+ * @subsection nanohttp_mime_client_response_sec Read the server response
+ *
+ * @subsection nanohttp_mime_client_cleanup_sec Client cleanup
+ *
+ * @secion nanohttp_mime_server_sec nanoHTTP server with MIME attachments
+ *
+ * @subsection nanohttp_mime_server_init_sec Server initialization
+ *
+ * @subsection nanohttp_mime_server_cleanup_sec Server cleanup
*
* @author Ferhat Ayaz
- * @version $Revision: 1.14 $
+ * @version $Revision: 1.15 $
*
* @see http://www.ietf.org/rfc/rfc2045.txt
* @see http://www.ietf.org/rfc/rfc2046.txt
diff --git a/nanohttp/nanohttp-server.h b/nanohttp/nanohttp-server.h
index bdb421c..53eb4a8 100644
--- a/nanohttp/nanohttp-server.h
+++ b/nanohttp/nanohttp-server.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-server.h,v 1.34 2006/12/31 17:24:22 m0gg Exp $
+ * $Id: nanohttp-server.h,v 1.35 2007/01/01 18:58:05 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -321,10 +321,9 @@ extern void httpd_set_headers(httpd_conn_t * conn, hpair_t * header);
extern int httpd_add_header(httpd_conn_t * conn, const char *key, const char *value);
extern void httpd_add_headers(httpd_conn_t * conn, const hpair_t * values);
-/*
- * XXX: move to nanohttp-mime.c
+/**
*
- * MIME support httpd_mime_* function set
+ * @todo move to nanohttp-mime.c merge with httpc_mime_* functions
*
*/
@@ -359,6 +358,42 @@ extern herror_t httpd_mime_send_file(httpd_conn_t * conn, const char *content_id
*/
extern herror_t httpd_mime_end(httpd_conn_t * conn);
+/**
+ *
+ * Send a minimalistic HTML error document with HTTP status 500.
+ *
+ * @see HTTP_STATUS_500_REASON_PHRASE
+ *
+ */
+extern herror_t httpd_send_internal_error(httpd_conn_t * conn, const char *msg);
+
+/**
+ *
+ * Send a minimalistic HTML error document with HTTP status 501.
+ *
+ * @see HTTP_STATUS_501_REASON_PHRASE
+ *
+ */
+extern herror_t httpd_send_not_implemented(httpd_conn_t *conn, const char *msg);
+
+/**
+ *
+ * Send a minimalistic HTML error document with HTTP status 404.
+ *
+ * @see HTTP_STATUS_401_REASON_PHRASE
+ *
+ */
+extern herror_t httpd_send_bad_request(httpd_conn_t *conn, const char *msg);
+
+/**
+ *
+ * Send a minimalistc HTML error document with HTTP status 401.
+ *
+ * @see HTTP_STATUS_404_REASON_PHRASE
+ *
+ */
+extern herror_t httpd_send_unauthorized(httpd_conn_t *conn, const char *realm);
+
#ifdef __cplusplus
}
#endif