You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by su...@apache.org on 2008/06/06 12:14:14 UTC
svn commit: r663880 - in
/webservices/axis2/trunk/c/src/core/transport/http/server/IIS:
axis2_iis_worker.c axis2_iis_worker.h axis2_isapi_plugin.c
axis2_isapi_plugin.h iis_iaspi_plugin_51/axis2_isapi_51.c mod_axis2.def
Author: supun
Date: Fri Jun 6 03:14:13 2008
New Revision: 663880
URL: http://svn.apache.org/viewvc?rev=663880&view=rev
Log:
IIS 6 and 7 Integration. Now this module can work as a wild card script map for IIS 6 and 7.
Removed:
webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_isapi_plugin.h
Modified:
webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.c
webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.h
webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_isapi_plugin.c
webservices/axis2/trunk/c/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c
webservices/axis2/trunk/c/src/core/transport/http/server/IIS/mod_axis2.def
Modified: webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.c?rev=663880&r1=663879&r2=663880&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.c Fri Jun 6 03:14:13 2008
@@ -168,10 +168,14 @@
ret_val = lpECB->GetServerVariable(lpECB->ConnID, "SERVER_PORT", port, &cbSize);
cbSize = INTERNET_MAX_PATH_LENGTH;
ret_val = lpECB->GetServerVariable(lpECB->ConnID, "HTTP_URL", redirect_url, &cbSize);
- axis2_worker_get_original_url(redirect_url, original_url);
+ /* We have a mapped URL only when the server version is 5 or less than that. */
+ if (server_version <= 5)
+ {
+ axis2_worker_get_original_url(redirect_url, original_url);
+ }
/* create the url using the above variables */
- sprintf(req_url, "%s%s%s%s", "http", server_name, port, original_url);
+ sprintf(req_url, "%s%s%s%s", "http://", server_name, port, original_url);
out_stream = axutil_stream_create_basic(env);
out_desc = axis2_conf_get_transport_out(
axis2_conf_ctx_get_conf (iis_worker->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_HTTP);
Modified: webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.h?rev=663880&r1=663879&r2=663880&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.h (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_iis_worker.h Fri Jun 6 03:14:13 2008
@@ -33,6 +33,7 @@
typedef struct axis2_iis_worker axis2_iis_worker_t;
+int server_version;
int AXIS2_CALL
axis2_iis_worker_process_request(
@@ -53,13 +54,6 @@
axis2_char_t * repo_path);
-
-#define AXIS2_IIS_WORKER_PROCESS_REQUEST(iis_worker, env, request) \
- axis2_iis_worker_process_request( \
- iis_worker, env, request)
-#define AXIS2_IIS_WORKER_FREE(iis_worker, env) \
- axis2_iis_worker_free( iis_worker, env)
-
#ifdef __cplusplus
}
#endif /*
Modified: webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_isapi_plugin.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_isapi_plugin.c?rev=663880&r1=663879&r2=663880&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_isapi_plugin.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/IIS/axis2_isapi_plugin.c Fri Jun 6 03:14:13 2008
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
@@ -23,281 +23,448 @@
#include <httpfilt.h>
#include <httpext.h>
-
-/* Axis headers */
-#include <axutil_error_default.h>
-#include <axutil_log_default.h>
-#include <axutil_thread_pool.h>
-#include <axiom_xml_reader.h>
-#include <axutil_log.h>
-
-#include "axis2_isapi_plugin.h"
-#include "axis2_iis_worker.h"
#include "axis2_iis_constants.h"
+#include "axis2_iis_worker.h"
-#define AXIS2_IIS_LOG_FILE_TAG ("log_file")
-#define AXIS2_IIS_LOG_LEVEL_TAG ("log_level")
-#define AXIS2_IIS_REPO_PATH_TAG ("axis2c_home")
-#define AXIS2_IIS_EXTENSION_URI_TAG ("extension_uri")
-#define AXIS2_IIS_REDIRECT_WORD_TAG ("redirect_uri")
-
-#define AXIS2_IIS_LOG_TRACE_VERB ("trace")
-#define AXIS2_IIS_LOG_ERROR_VERB ("error")
-#define AXIS2_IIS_LOG_INFO_VERB ("info")
-#define AXIS2_IIS_LOG_USER_VERB ("user")
-#define AXIS2_IIS_LOG_CRITICAL_VERB ("critical")
-#define AXIS2_IIS_LOG_WARN_VERB ("warning")
-#define AXIS2_IIS_LOG_DEBUG_VERB ("debug")
-
-#define MAX_FILE_PATH 256
-#define REGISTRY_LOCATION ("Software\\Apache Axis2c\\IIS ISAPI Redirector")
-static int is_inited = FALSE;
-static axis2_iis_worker_t *axis2_worker = NULL;
-static const axutil_env_t *axutil_env = NULL;
-static axis2_char_t repo_path[MAX_FILE_PATH] = "c:\\axis2c";
-static axis2_char_t log_file[MAX_FILE_PATH] = "axis2.log";
-static axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_CRITICAL;
-static axis2_char_t redirect_word[INTERNET_MAX_URL_LENGTH] =
-"/axis2/mod_axis2_IIS.dll\?";
-
-/*
- * This is a utility functipn for reading configuration data from the registery.
- */
-static axis2_status_t read_registery_init_data(
- );
+/* Axis headers */
+#include <axutil_error_default.h>
+#include <axutil_log_default.h>
+#include <axutil_thread_pool.h>
+#include <axiom_xml_reader.h>
+#include <axutil_log.h>
-/*
- * Utility function for reading
- */
-static axis2_status_t get_registry_config_parameter(
- HKEY hkey,
- const char *tag,
- char *b,
- DWORD sz);
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+#endif
+
+#define AXIS2_IIS_LOG_FILE_TAG "log_file"
+#define AXIS2_IIS_LOG_LEVEL_TAG "log_level"
+#define AXIS2_IIS_REPO_PATH_TAG "axis2c_home"
+#define AXIS2_IIS_EXTENSION_URI_TAG "extension_uri"
+#define AXIS2_IIS_REDIRECT_WORD_TAG "redirect_uri"
+#define AXIS2_IIS_AXIS2_LOCATION "axis2_location"
+#define AXIS2_IIS_SERVICE_URL_PREFIX "services"
+
+#define AXIS2_IIS_LOG_TRACE_VERB "trace"
+#define AXIS2_IIS_LOG_ERROR_VERB "error"
+#define AXIS2_IIS_LOG_INFO_VERB "info"
+#define AXIS2_IIS_LOG_USER_VERB "user"
+#define AXIS2_IIS_LOG_CRITICAL_VERB "critical"
+#define AXIS2_IIS_LOG_WARN_VERB "warning"
+#define AXIS2_IIS_LOG_DEBUG_VERB "debug"
+
+#define MAX_FILE_PATH 256
+#define REGISTRY_LOCATION "Software\\Apache Axis2c\\IIS ISAPI Redirector"
+
+static int is_inited = FALSE;
+static axis2_iis_worker_t *axis2_worker = NULL;
+static const axutil_env_t *axutil_env = NULL;
+
+/* Configuration parameters */
+static axis2_char_t *axis2_location = "axis2";
+static axis2_char_t *axis2_service_url_prefix= "services";
+static axis2_char_t repo_path[MAX_FILE_PATH];
+static axis2_char_t log_file[MAX_FILE_PATH];
+static axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_CRITICAL;
+
+/* Path variables */
+static char szOriginalPath[_MAX_PATH + 1];
+static char szPath[_MAX_PATH + 1];
+
+axis2_char_t general_error[] = "<html>\r\n"
+ "<head><title> An IIS server error occurred. </title></head>\r\n"
+ "<h1> An IIS server error occurred </h1>\r\n"
+ "<hr>\r\n"
+ "An error occurred in IIS while processing this request.";
+
+axis2_char_t initializing_error[] = "<html>\r\n"
+ "<head><title> An IIS server error occurred. </title></head>\r\n"
+ "<h1> An IIS server error occurred </h1>\r\n"
+ "<hr>\r\n"
+ "An error occurred while initilizing Axis2/C. Please verify the configuration";
+
+
+/*
+ * This is a utility functipn for reading configuration data from the registery.
+ */
+static axis2_status_t AXIS2_CALL
+read_registery_init_data();
+
+/*
+ * Utility function for reading
+ */
+static axis2_status_t AXIS2_CALL get_registry_config_parameter(
+ HKEY hkey,
+ const char *tag,
+ char *b,
+ DWORD sz);
+
+/*
+ * Parse the given string and return the corresponding log_level
+ */
+axutil_log_levels_t AXIS2_CALL axis2_iis_parse_log_level(char level[]);
/*
- * Parse the given string and return the corresponding log_level
- */
-axutil_log_levels_t axis2_iis_parse_log_level(char level[]);
+ * Initialize axis. This function is called in the begining of the module loading.
+ * It initializes the axis by reading values from the configuration and creating the
+ * required structures for the axis2c
+*/
+axis2_status_t AXIS2_CALL init_axis2();
+
+/*
+ * This is the function to be called after the processing
+ * is over for non Axis2 requets
+ */
+VOID
+WINAPI
+ExecUrlCompletion (
+ EXTENSION_CONTROL_BLOCK * pecb,
+ PVOID pContext,
+ DWORD cbIO,
+ DWORD dwError
+ );
+
+/*
+ * If somethign went wrong in the IIS server when
+ * we are proccessing we send this
+ */
+BOOL
+send_error(
+ EXTENSION_CONTROL_BLOCK * pecb,
+ CHAR error[]);
+
+axis2_status_t AXIS2_CALL init_axis2();
+
+BOOL
+WINAPI
+GetExtensionVersion(HSE_VERSION_INFO * pVer)
+{
+ pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
+ HSE_VERSION_MAJOR);
+ strncpy( pVer->lpszExtensionDesc,
+ "WildCardMap Sample ISAPI Extension", HSE_MAX_EXT_DLL_NAME_LEN );
+
+ pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1] = '\0';
+ server_version = 5;
+ return TRUE;
+}
+
+DWORD
+WINAPI
+HttpExtensionProc(EXTENSION_CONTROL_BLOCK * pecb)
+
+{
+ HSE_EXEC_URL_INFO ExecUrlInfo;
+ DWORD cbData = INTERNET_MAX_URL_LENGTH;
+ char url[INTERNET_MAX_URL_LENGTH];
+ axis2_bool_t is_for_us = AXIS2_FALSE;
+
+ /* Get the URL */
+ if ( pecb->GetServerVariable( pecb->ConnID,
+ "URL",
+ url,
+ &cbData ) == FALSE )
+ {
+ return HSE_STATUS_ERROR;
+ }
+ /* Check weather we have a request for Axis2/C */
+ if (strlen(url) > strlen(axis2_location))
+ {
+ int i = 0;
+ is_for_us = AXIS2_TRUE;
+ while (axis2_location[i] != '\0')
+ {
+ if (axis2_location[i] != (url + 1)[i]) {
+ is_for_us = AXIS2_FALSE;
+ break;
+ }
+ i++;
+ }
+ }
+
+ if (is_for_us)
+ {
+ if (!is_inited)
+ {
+ DWORD dwBufferSize = 0;
+ axis2_char_t server_software[256];
+ axis2_char_t *version = NULL;
-/*
- * This is the entry point for the extention. The filter will redirect a
- * given request to this extentiom.
- */
-BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO * pVer)
-{
- /* Create the extension version string, and copy string to HSE_VERSION_INFO structure.*/
- pVer->dwExtensionVersion =
- MAKELONG(HSE_VERSION_MINOR, HSE_VERSION_MAJOR);
- /* Copy description string into HSE_VERSION_INFO structure.*/
- strcpy(pVer->lpszExtensionDesc, "Apache Axis2c ISAPI Redirector");
- return TRUE;
-}
+ ZeroMemory(szOriginalPath, sizeof szOriginalPath);
+ dwBufferSize = sizeof szOriginalPath;
-/*
- * This is the entri point for every request to the axis2c. The redirected response
- * will come here. This method invoke the axis2 engine and build the response result
- * and send it.
- */
-DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB)
-{
- DWORD rc = HSE_STATUS_ERROR;
- lpECB->dwHttpStatusCode = HTTP_INTERNAL_SERVER_ERROR;
- if (axis2_worker)
- {
- /* windows cannot find the correct dlls unless the dir is set
- but we want to reset to previous dir after the load */
- char szOriginalPath[_MAX_PATH + 1];
- char szPath[_MAX_PATH + 1];
- DWORD dwBufferSize = 0;
- ZeroMemory(szOriginalPath, sizeof szOriginalPath);
- dwBufferSize = sizeof szOriginalPath;
#if _WIN32_WINNT >= 0x0502
- GetDllDirectory( dwBufferSize, szOriginalPath );
+ GetDllDirectory( dwBufferSize, szOriginalPath );
#else
- GetCurrentDirectory( dwBufferSize, szOriginalPath );
+ GetCurrentDirectory( dwBufferSize, szOriginalPath );
#endif
-
- ZeroMemory(szPath, sizeof szPath);
- dwBufferSize = sizeof szPath;
- lpECB->GetServerVariable(lpECB->ConnID, "APPL_PHYSICAL_PATH", szPath, &dwBufferSize);
- if ( strlen( szPath ) > 0 )
- {
- /* windows cannot find the correct dlls unless the path is set */
+ ZeroMemory(szPath, sizeof szPath);
+ dwBufferSize = sizeof szPath;
+ /* Get the current physical paht */
+ if (pecb->GetServerVariable(pecb->ConnID, "APPL_PHYSICAL_PATH", szPath, &dwBufferSize) == FALSE)
+ {
+ send_error(pecb, initializing_error);
+ return HSE_STATUS_ERROR;
+ }
+ /* Retrieve the server version */
+ dwBufferSize = 32;
+ if (pecb->GetServerVariable(pecb->ConnID, "SERVER_SOFTWARE", server_software, &dwBufferSize) == FALSE)
+ {
+ send_error(pecb, initializing_error);
+ return HSE_STATUS_ERROR;
+ }
+ version = axutil_strchr(server_software, '/');
+ if (version)
+ {
+ server_version = atoi(version + 1);
+ }
#if _WIN32_WINNT >= 0x0502
SetDllDirectory( szPath );
#else
SetCurrentDirectory( szPath );
#endif
- }
+ /* If we haven't initialized axis2/c before initialization failed */
+ if (AXIS2_FAILURE == init_axis2())
+ {
+ send_error(pecb, initializing_error);
+ }
+#if _WIN32_WINNT >= 0x0502
+ SetDllDirectory( szOriginalPath );
+#else
+ SetCurrentDirectory( szOriginalPath );
+#endif
+ }
- AXIS2_IIS_WORKER_PROCESS_REQUEST(axis2_worker, axutil_env, lpECB);
+ /* Windows cannot find the correct dlls unless the path is set*/
+#if _WIN32_WINNT >= 0x0502
+ SetDllDirectory( szPath );
+#else
+ SetCurrentDirectory( szPath );
+#endif
+ pecb->dwHttpStatusCode = HTTP_INTERNAL_SERVER_ERROR;
+ /* We are sure that worker is not NULL since it is NULL init_axis2 would have failed */
+ axis2_iis_worker_process_request(axis2_worker, axutil_env, pecb);
- /* windows cannot find the correct dlls unless the dir is set
- but we want to reset to previous dir after the load */
+ /* Windows cannot find the correct dlls unless the dir is set
+ but we want to reset to previous dir after the load */
#if _WIN32_WINNT >= 0x0502
SetDllDirectory( szOriginalPath );
#else
SetCurrentDirectory( szOriginalPath );
#endif
+ return HSE_STATUS_SUCCESS;
}
- else
- return HSE_STATUS_ERROR;
- return HSE_STATUS_SUCCESS;
-}
-
-/**
- * This method initializes the axis2 engine. All the required variables are set to
- * their initial values in this method.
-*/
-axis2_status_t init_axis2()
-{
- /*
- * These are the varibles required to initialize axis.
- */
- axis2_status_t status = FALSE;
- /* We need to init xml readers before we go into threaded env */
- if (!is_inited)
- {
- axiom_xml_reader_init();
- status = read_registery_init_data();
- axutil_error_init();
- axutil_env = axutil_env_create_all(log_file, log_level);
- if (axutil_env == NULL)
- {
- return FALSE;
- }
- axis2_worker = axis2_iis_worker_create(axutil_env, repo_path);
- if (axis2_worker == NULL)
- {
- return FALSE;
- }
- is_inited = TRUE;
- }
- return TRUE;
-}
-BOOL WINAPI TerminateExtension(DWORD dwFlags)
-{
- return TRUE;
-}
-axis2_status_t axis2_terminate()
-{
- /* axiom_xml_reader_cleanup();*/
- /* AXIS2_IIS_WORKER_FREE(axis2_worker, axutil_env);*/
- /* axutil_env_free(axutil_env);*/
- return TRUE;
-}
-
-axis2_status_t get_extension_url(char url[], char ret_url[])
-{
- /* Should contain "/axis2/"*/
- ret_url[0] = '\0';
-
- /* The url should begin with "/axis2/"*/
- if (url[0] == '/' && (url[1] == 'a' || url[1] == 'A')
- &&(url[2] == 'x' || url[2] == 'X')
- &&(url[3] == 'i' || url[3] == 'I')
- &&(url[4] == 's' || url[4] == 'S')
- &&url[5] == '2' && url[6] == '/')
- {
- /* Append the string to redirect the request*/
- strcpy(ret_url, redirect_word);
- strcat(ret_url, &url[7]);
- return TRUE;
- }
- if (url[0] == '/' && (url[1] == 'a' || url[1] == 'A')
- &&(url[2] == 'x' || url[2] == 'X')
- &&(url[3] == 'i' || url[3] == 'I')
- &&(url[4] == 's' || url[4] == 'S') &&url[5] == '2' && url[6] == '\0')
- {
- strcpy(ret_url, redirect_word);
- return TRUE;
- }
- return FALSE;
-}
-axis2_status_t read_registery_init_data()
-{
- long rc = 0;
- axis2_status_t ok = TRUE;
- char tmpbuf[INTERNET_MAX_URL_LENGTH];
- HKEY hkey;
-
- rc =
- RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_LOCATION, (DWORD) 0,
- KEY_READ, &hkey);
- if (ERROR_SUCCESS != rc)
- {
- return FALSE;
- }
- if (get_registry_config_parameter
- (hkey, AXIS2_IIS_REPO_PATH_TAG, tmpbuf, sizeof(repo_path)))
- {
- strcpy(repo_path, tmpbuf);
- }
- else
- {
- ok = FALSE;
- }
- if (get_registry_config_parameter
- (hkey, AXIS2_IIS_LOG_FILE_TAG, tmpbuf, sizeof(log_file)))
- {
- strcpy(log_file, tmpbuf);
- }
- else
- {
- ok = FALSE;
- }
- if (get_registry_config_parameter
- (hkey, AXIS2_IIS_LOG_LEVEL_TAG, tmpbuf, sizeof(tmpbuf)))
- {
- log_level = axis2_iis_parse_log_level(tmpbuf);
- }
- RegCloseKey(hkey);
- return ok;
-}
-axutil_log_levels_t axis2_iis_parse_log_level(char level[])
-{
- if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_TRACE_VERB))
- {
- return AXIS2_LOG_LEVEL_TRACE;
- }
- if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_DEBUG_VERB))
- {
- return AXIS2_LOG_LEVEL_DEBUG;
- }
- if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_INFO_VERB))
- {
- return AXIS2_LOG_LEVEL_INFO;
- }
- if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_USER_VERB))
- {
- return AXIS2_LOG_LEVEL_USER;
- }
- if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_WARN_VERB))
- {
- return AXIS2_LOG_LEVEL_WARNING;
- }
- if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_ERROR_VERB))
- {
- return AXIS2_LOG_LEVEL_ERROR;
- }
- if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_CRITICAL_VERB))
- {
- return AXIS2_LOG_LEVEL_CRITICAL;
- }
- return AXIS2_LOG_LEVEL_CRITICAL;
-}
-axis2_status_t get_registry_config_parameter(HKEY hkey, const char *tag,
- char *b, DWORD sz)
-{
- DWORD type = 0;
- LONG lrc;
+ else if (server_version >= 6)
+ {
+ /* For IIS 5.1 or earlier this code is never executed. Since the URL is
+ redirected to Axis2/C by the Filter */
- lrc = RegQueryValueEx(hkey, tag, (LPDWORD) 0, &type, (LPBYTE) b, &sz);
- if ((ERROR_SUCCESS != lrc) || (type != REG_SZ))
- {
- return FALSE;
- }
- b[sz] = '\0';
- return TRUE;
-}
+ /* If not for Axis2/C let the request go to who ever wants it */
+ ExecUrlInfo.pszUrl = NULL; /* Use original request URL */
+ ExecUrlInfo.pszMethod = NULL; /* Use original request method */
+ ExecUrlInfo.pszChildHeaders = NULL; /* Use original request headers */
+ ExecUrlInfo.pUserInfo = NULL; /* Use original request user info */
+ ExecUrlInfo.pEntity = NULL; /* Use original request entity */
+
+ /* Provent recursion */
+ ExecUrlInfo.dwExecUrlFlags = HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR;
+
+ /* Associate the completion routine and the current URL with this request. */
+ if ( pecb->ServerSupportFunction( pecb->ConnID,
+ HSE_REQ_IO_COMPLETION,
+ ExecUrlCompletion,
+ NULL,
+ NULL) == FALSE )
+ {
+ return HSE_STATUS_ERROR;
+ }
+
+ /* Ok, now that everything is set up, let's call the child request */
+ if ( pecb->ServerSupportFunction( pecb->ConnID,
+ HSE_REQ_EXEC_URL,
+ &ExecUrlInfo,
+ NULL,
+ NULL ) == FALSE )
+ {
+ return HSE_STATUS_ERROR;
+ }
+ /* Return pending and let the completion clean up */
+ return HSE_STATUS_PENDING;
+ }
+ return HSE_STATUS_ERROR;
+}
+
+VOID
+WINAPI
+ExecUrlCompletion (
+ EXTENSION_CONTROL_BLOCK * pecb,
+ PVOID pContext,
+ DWORD cbIO,
+ DWORD dwError
+ )
+{
+ /* We are done so notify */
+ pecb->ServerSupportFunction(
+ pecb->ConnID,
+ HSE_REQ_DONE_WITH_SESSION,
+ NULL,
+ NULL,
+ NULL);
+}
+
+
+BOOL
+send_error(
+ EXTENSION_CONTROL_BLOCK * pecb,
+ axis2_char_t error[])
+{
+ DWORD cbData;
+ pecb->dwHttpStatusCode = 500;
+ /* Send headers and response */
+ pecb->ServerSupportFunction( pecb->ConnID,
+ HSE_REQ_SEND_RESPONSE_HEADER,
+ "500 Server Error",
+ NULL,
+ (LPDWORD)"Content-Type: text/html\r\n\r\n" );
+
+ cbData = axutil_strlen( error );
+ return pecb->WriteClient( pecb->ConnID,
+ error,
+ &cbData,
+ HSE_IO_SYNC );
+}
+
+axis2_status_t AXIS2_CALL read_registery_init_data()
+{
+ long rc = 0;
+ axis2_status_t ok = TRUE;
+ char tmpbuf[INTERNET_MAX_URL_LENGTH];
+ HKEY hkey;
+ AXIS2_IMPORT extern axis2_char_t *axis2_request_url_prefix;
+
+ rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_LOCATION, (DWORD) 0, KEY_READ, &hkey);
+ if (ERROR_SUCCESS != rc)
+ {
+ return AXIS2_FAILURE;
+ }
+ if (get_registry_config_parameter(hkey, AXIS2_IIS_REPO_PATH_TAG, tmpbuf, sizeof(repo_path)))
+ {
+ strcpy(repo_path, tmpbuf);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ if (get_registry_config_parameter(hkey, AXIS2_IIS_LOG_FILE_TAG, tmpbuf, sizeof(log_file)))
+ {
+ strcpy(log_file, tmpbuf);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ if (get_registry_config_parameter(hkey, AXIS2_IIS_LOG_LEVEL_TAG, tmpbuf, sizeof(tmpbuf)))
+ {
+ log_level = axis2_iis_parse_log_level(tmpbuf);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ if (get_registry_config_parameter(hkey, AXIS2_IIS_SERVICE_URL_PREFIX, tmpbuf, sizeof(tmpbuf)))
+ {
+ axis2_request_url_prefix = strdup(tmpbuf);
+ }
+ if (get_registry_config_parameter(hkey, AXIS2_IIS_AXIS2_LOCATION, tmpbuf, sizeof(tmpbuf)))
+ {
+ axis2_location = strdup(tmpbuf);
+ }
+ RegCloseKey(hkey);
+ return ok;
+}
+
+axutil_log_levels_t AXIS2_CALL
+axis2_iis_parse_log_level(char level[])
+{
+ if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_TRACE_VERB))
+ {
+ return AXIS2_LOG_LEVEL_TRACE;
+ }
+ if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_DEBUG_VERB))
+ {
+ return AXIS2_LOG_LEVEL_DEBUG;
+ }
+ if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_INFO_VERB))
+ {
+ return AXIS2_LOG_LEVEL_INFO;
+ }
+ if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_USER_VERB))
+ {
+ return AXIS2_LOG_LEVEL_USER;
+ }
+ if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_WARN_VERB))
+ {
+ return AXIS2_LOG_LEVEL_WARNING;
+ }
+ if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_ERROR_VERB))
+ {
+ return AXIS2_LOG_LEVEL_ERROR;
+ }
+ if (0 == AXIS2_STRICMP(level, AXIS2_IIS_LOG_CRITICAL_VERB))
+ {
+ return AXIS2_LOG_LEVEL_CRITICAL;
+ }
+ return AXIS2_LOG_LEVEL_DEBUG;
+}
+
+axis2_status_t AXIS2_CALL
+get_registry_config_parameter(HKEY hkey, const char *tag, char *b, DWORD sz)
+{
+ DWORD type = 0;
+ LONG lrc;
+
+ lrc = RegQueryValueEx(hkey, tag, (LPDWORD) 0, &type, (LPBYTE) b, &sz);
+ if ((ERROR_SUCCESS != lrc) || (type != REG_SZ))
+ {
+ return FALSE;
+ }
+ b[sz] = '\0';
+ return TRUE;
+}
+
+/**
+ * This method initializes the axis2 engine. All the required variables are set to
+ * their initial values in this method.
+*/
+axis2_status_t AXIS2_CALL init_axis2()
+{
+ /*
+ * These are the varibles required to initialize axis.
+ */
+ axis2_status_t status = FALSE;
+ /* We need to init xml readers before we go into threaded env */
+ if (!is_inited)
+ {
+ axiom_xml_reader_init();
+ status = read_registery_init_data();
+ if (status == AXIS2_FAILURE)
+ {
+ return AXIS2_FAILURE;
+ }
+ axutil_error_init();
+ /* Initialize the environement */
+ axutil_env = axutil_env_create_all(log_file, log_level);
+ if (!axutil_env)
+ {
+ return AXIS2_FAILURE;
+ }
+ axis2_worker = axis2_iis_worker_create(axutil_env, repo_path);
+ if (!axis2_worker)
+ {
+ return AXIS2_FAILURE;
+ }
+ is_inited = AXIS2_TRUE;
+ return AXIS2_SUCCESS;
+ }
+ return AXIS2_FAILURE;
+}
Modified: webservices/axis2/trunk/c/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c?rev=663880&r1=663879&r2=663880&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c Fri Jun 6 03:14:13 2008
@@ -24,79 +24,77 @@
#include "..\\axis2_isapi_plugin.h"
#include "..\\axis2_iis_constants.h"
-
+static axis2_char_t redirect_word[INTERNET_MAX_URL_LENGTH] = "/axis2/mod_axis2_IIS.dll\?";
/*
-This function is called by the IIS server at the server
-initialization. So this is the ideal plcae for initializing
-axis2c.
-*/
- BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer)
-{
-
DWORD rc = FALSE;
-
ULONG http_filter_revision = HTTP_FILTER_REVISION;
-
pVer->dwFilterVersion = pVer->dwServerFilterVersion;
-
if (pVer->dwFilterVersion > http_filter_revision)
- {
-
pVer->dwFilterVersion = http_filter_revision;
-
}
-
- /*
- Receive notifictions when
- 1. Server preprocessed the headers.
- 2. Log
- 3. All the request coming in secure and none secure ports.
- */
- pVer->dwFlags =
- (SF_NOTIFY_ORDER_HIGH |
SF_NOTIFY_PREPROC_HEADERS |
-
SF_NOTIFY_SECURE_PORT |
SF_NOTIFY_NONSECURE_PORT |
-
SF_NOTIFY_AUTH_COMPLETE
);
-
- /* Give a short discription about the module.*/
- strcpy(pVer->lpszFilterDesc, "axis2c filter");
-
- /* initialize axis2*/
- rc = init_axis2();
-
return rc;
-
}
-
-
+ * Search a given uri to find weather it matches a uri for the axis2
+ * The uri format for axis2 is of the form
+ * scheme://server:port/axis2/other_parts
+ * This function search a give uri for the /axis2/. If a match
+ * is found it will replace the /axis2 part of the url with /axis2/mod_iis.dll?
+*/
+axis2_status_t AXIS2_CALL
+get_extension_url(char url[], char ret_url[]);
/*
-When a notification happens this function is called by the IIS.
+ * This function is called by the IIS server at the server
+ * initialization. So this is the ideal plcae for initializing
+ * axis2c.
*/
- DWORD WINAPI HttpFilterProc(
PHTTP_FILTER_CONTEXT pfc,
-
DWORD notificationType,
-
LPVOID pvNotification)
-{
-
DWORD bufferLength = INTERNET_MAX_URL_LENGTH;
-
char url[INTERNET_MAX_URL_LENGTH];
-
char modified_url[INTERNET_MAX_URL_LENGTH];
-
if (notificationType == SF_NOTIFY_PREPROC_HEADERS)
-
- {
-
pfc->GetServerVariable(pfc, "HTTP_URL", url, &bufferLength);
-
if (get_extension_url(url, modified_url))
-
- {
-
((PHTTP_FILTER_PREPROC_HEADERS) pvNotification)->SetHeader(pfc,
- "url",
- modified_url);
-
return SF_STATUS_REQ_HANDLED_NOTIFICATION;
-
}
-
}
-
return SF_STATUS_REQ_NEXT_NOTIFICATION;
-
}
-
-
+BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer)
+{
ULONG http_filter_revision = HTTP_FILTER_REVISION;
pVer->dwFilterVersion = pVer->dwServerFilterVersion;
if (pVer->dwFilterVersion > http_filter_revision)
+ {
pVer->dwFilterVersion = http_filter_revision;
}
+
+ /*
+ Receive notifictions when
+ 1. Server preprocessed the headers.
+ 2. Log
+ 3. All the request coming in secure and none secure ports.
+ */
+ pVer->dwFlags =
+ (SF_NOTIFY_ORDER_HIGH |
SF_NOTIFY_PREPROC_HEADERS |
SF_NOTIFY_SECURE_PORT |
SF_NOTIFY_NONSECURE_PORT |
SF_NOTIFY_AUTH_COMPLETE
);
+
+ /* Give a short discription about the module.*/
+ strcpy(pVer->lpszFilterDesc, "axis2c filter");
+ /* initialize axis2*/
+
return TRUE;
}
/*
-This is the exit point of the filter. Here we shut down
-the axis2 engine.
+When a notification happens this function is called by the IIS.
*/
- BOOL WINAPI TerminateFilter(DWORD dwfalgs)
+DWORD WINAPI HttpFilterProc(
PHTTP_FILTER_CONTEXT pfc,
DWORD notificationType,
LPVOID pvNotification)
+{
DWORD bufferLength = INTERNET_MAX_URL_LENGTH;
char url[INTERNET_MAX_URL_LENGTH];
char modified_url[INTERNET_MAX_URL_LENGTH];
+
if (notificationType == SF_NOTIFY_PREPROC_HEADERS)
+ {
pfc->GetServerVariable(pfc, "HTTP_URL", url, &bufferLength);
if (get_extension_url(url, modified_url))
+ {
((PHTTP_FILTER_PREPROC_HEADERS) pvNotification)->SetHeader(pfc,
+ "url",
+ modified_url);
return SF_STATUS_REQ_HANDLED_NOTIFICATION;
}
}
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
+
+axis2_status_t AXIS2_CALL
+get_extension_url(char url[], char ret_url[])
{
-
return axis2_terminate();
-
}
+ /* Should contain "/axis2/"*/
+ ret_url[0] = '\0';
-
+ /* The url should begin with "/axis2/"*/
+ if (url[0] == '/' && (url[1] == 'a' || url[1] == 'A')
+ &&(url[2] == 'x' || url[2] == 'X')
+ &&(url[3] == 'i' || url[3] == 'I')
+ &&(url[4] == 's' || url[4] == 'S')
+ &&url[5] == '2' && url[6] == '/')
+ {
+ /* Append the string to redirect the request*/
+ strcpy(ret_url, redirect_word);
+ strcat(ret_url, &url[7]);
+ return TRUE;
+ }
+ if (url[0] == '/' && (url[1] == 'a' || url[1] == 'A')
+ &&(url[2] == 'x' || url[2] == 'X')
+ &&(url[3] == 'i' || url[3] == 'I')
+ &&(url[4] == 's' || url[4] == 'S') &&url[5] == '2' && url[6] == '\0')
+ {
+ strcpy(ret_url, redirect_word);
+ return TRUE;
+ }
+ return FALSE;
+}
\ No newline at end of file
Modified: webservices/axis2/trunk/c/src/core/transport/http/server/IIS/mod_axis2.def
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/IIS/mod_axis2.def?rev=663880&r1=663879&r2=663880&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/IIS/mod_axis2.def (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/IIS/mod_axis2.def Fri Jun 6 03:14:13 2008
@@ -1,9 +1,7 @@
LIBRARY "mod_axis2_IIS"
EXPORTS
- HttpFilterProc
- GetFilterVersion
GetExtensionVersion
- HttpExtensionProc
- TerminateFilter
- TerminateExtension
\ No newline at end of file
+ HttpExtensionProc
+ GetFilterVersion
+ HttpFilterProc
\ No newline at end of file