You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by su...@apache.org on 2004/05/24 07:54:55 UTC
cvs commit: ws-axis/c/vc/server/apache2_0 Apache2_0Module.dsp
susantha 2004/05/23 22:54:55
Modified: c/include/axis/server XMLParser.h
c/src/engine Axis.cpp
c/src/server/apache ApacheTransport.cpp ApacheTransport.h
c/src/xml/xerces SoapParserXerces.cpp XercesHandler.cpp
XercesHandler.h
c/vc/server/apache2_0 Apache2_0Module.dsp
Added: c/src/server/apache2 Apache2Transport.cpp Apache2Transport.h
mod_axis2.cpp
Removed: c/src/server/apache2 mod_axis2.c
Log:
Changed Apache 2 module, Added Apache2Transport class
Corrected xerces parser problem. Probably has fixed the empty tag bug too.
Revision Changes Path
1.13 +1 -1 ws-axis/c/include/axis/server/XMLParser.h
Index: XMLParser.h
===================================================================
RCS file: /home/cvs/ws-axis/c/include/axis/server/XMLParser.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XMLParser.h 18 May 2004 11:09:08 -0000 1.12
+++ XMLParser.h 24 May 2004 05:54:55 -0000 1.13
@@ -25,7 +25,7 @@
* @class XMLParser
* @brief Interface that any parser wrapper should implement in order to be use
* in Axis as a XML PULL parser. Its the responsibility of the implementation
- * class to free and memory allocated inside the class. The class should not
+ * class to free any memory allocated inside the class. The class should not
* deallocate either the given input stream or any memory buffers that it gets
* from the stream.
* @author Susantha Kumara (susantha@opensource.lk, skumara@virtusa.com)
1.57 +1 -1 ws-axis/c/src/engine/Axis.cpp
Index: Axis.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/engine/Axis.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- Axis.cpp 24 May 2004 05:44:20 -0000 1.56
+++ Axis.cpp 24 May 2004 05:54:55 -0000 1.57
@@ -157,7 +157,7 @@
pStream->sendBytes("<html><body>\
<h1 align=\"center\">Welcome to Axis C++</h1>\
<br>\
- <h2 align=\"center\">List of Deployed Web services<br></h2>\
+ <h2 align=\"center\">List of Deployed Web services</h2><br>\
<table width=\"100%\" border=1 align=\"center\"><tbody>", NULL);
pStream->sendBytes
1.2 +1 -1 ws-axis/c/src/server/apache/ApacheTransport.cpp
Index: ApacheTransport.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/apache/ApacheTransport.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ApacheTransport.cpp 12 May 2004 07:36:46 -0000 1.1
+++ ApacheTransport.cpp 24 May 2004 05:54:55 -0000 1.2
@@ -23,7 +23,7 @@
#define AXIS_URI_EXTENSION "/axis"
/* Following is the character that should be used to separate the method name in
- * the SOAPAction header value. Ex: "http://localhost:80/axis/Calculator#Add"
+ * the SOAPAction header value. Ex: "Calculator#Add"
*/
#define SOAPACTION_METHODNAME_SEPARATOR "#"
1.2 +0 -3 ws-axis/c/src/server/apache/ApacheTransport.h
Index: ApacheTransport.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/apache/ApacheTransport.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ApacheTransport.h 12 May 2004 07:36:46 -0000 1.1
+++ ApacheTransport.h 24 May 2004 05:54:55 -0000 1.2
@@ -21,8 +21,6 @@
#if !defined(AXIS_APACHETRANSPORT_H__OF_AXIS_INCLUDED_)
#define AXIS_APACHETRANSPORT_H__OF_AXIS_INCLUDED_
-#define SIZEOFTRANSPORTBUFFER 256
-
#include <apache1_3/httpd.h>
#include <apache1_3/http_config.h>
#include <apache1_3/http_core.h>
@@ -60,7 +58,6 @@
AXIS_TRANSPORT_STATUS flushOutput();
private:
void* m_pContext;
- char m_Buffer[SIZEOFTRANSPORTBUFFER];
#ifndef CHUNCKED_DATA_SUPPORTED
BufferInfo* m_pBuffers;
#endif
1.1 ws-axis/c/src/server/apache2/Apache2Transport.cpp
Index: Apache2Transport.cpp
===================================================================
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* @author Susantha Kumara (susantha@opensource.lk, skumara@virtusa.com)
*
*/
#include "Apache2Transport.h"
#define AXIS_URI_EXTENSION "/axis"
/* Following is the character that should be used to separate the method name in
* the SOAPAction header value. Ex: "http://localhost:80/axis/Calculator#Add"
*/
#define SOAPACTION_METHODNAME_SEPARATOR "#"
Apache2Transport::Apache2Transport(void* pContext)
{
m_pContext = pContext;
#ifndef CHUNCKED_DATA_SUPPORTED
m_pBuffers = new BufferInfo[NO_OF_SERIALIZE_BUFFERS];
memset((void*)m_pBuffers, 0, sizeof(BufferInfo)*NO_OF_SERIALIZE_BUFFERS);
#endif
}
Apache2Transport::~Apache2Transport()
{
}
AXIS_TRANSPORT_STATUS Apache2Transport::sendBytes(const char* pcSendBuffer, const void* pBufferId)
{
#ifndef CHUNCKED_DATA_SUPPORTED
int index;
#endif
if (!pBufferId) /* temporary buffers should always sent immediately */
{
ap_rputs(pcSendBuffer, (request_rec*)m_pContext);
return TRANSPORT_FINISHED;
}
#ifdef CHUNCKED_DATA_SUPPORTED
// Do we need to send any headers and length of this chunk ?
ap_rputs(pcSendBuffer, (request_rec*)m_pContext);
/* Do we need to send any indication to mark the end of this
* chunk ?
*/
return TRANSPORT_FINISHED;
#else
for (index = 0; index < NO_OF_SERIALIZE_BUFFERS; index++)
{
if (!m_pBuffers[index].pcBuffer)
{
m_pBuffers[index].pcBuffer = pcSendBuffer;
m_pBuffers[index].pBufferId = pBufferId;
break;
}
}
return TRANSPORT_IN_PROGRESS;
#endif
}
void Apache2Transport::setTransportProperty(AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value)
{
const char* key = NULL;
switch (type)
{
case SOAPACTION_HEADER: /* needed only in the client side ? */
break;
case SERVICE_URI: /* need to set ? */
break;
case OPERATION_NAME: /* need to set ? */
break;
case SOAP_MESSAGE_LENGTH:
/* This is apache module and transport is http so the key */
key = "Content-Length";
break;
default:;
}
if (key)
{
ap_table_set(((request_rec*)m_pContext)->headers_out, key, value);
#ifdef CHUNCKED_DATA_SUPPORTED
ap_send_http_header((request_rec*)m_pContext);
/* Should we remove the sent headers ? */
#endif
}
}
AXIS_TRANSPORT_STATUS Apache2Transport::flushOutput()
{
#ifndef CHUNCKED_DATA_SUPPORTED
int contentLength = 0;
int index;
char strtonum[8];
#endif
#ifdef CHUNCKED_DATA_SUPPORTED
/* headers have already been sent. see set_transport_information
* http body too have been sent
* Do we need to send any indication to mark end of chuncked
* data ?
*/
#else
/* Calculate Content-Length and set header */
for (index = 0; index < NO_OF_SERIALIZE_BUFFERS; index++)
{
if (!m_pBuffers[index].pcBuffer)
break;
contentLength += strlen(m_pBuffers[index].pcBuffer);
}
if (contentLength != 0) /* do only if the http body is not empty. */
{
sprintf(strtonum, "%d", contentLength);
setTransportProperty(SOAP_MESSAGE_LENGTH, strtonum);
ap_send_http_header((request_rec*)m_pContext);
/* Send all buffers */
for (index = 0; index < NO_OF_SERIALIZE_BUFFERS; index++)
{
if (!m_pBuffers[index].pcBuffer)
break;
ap_rputs(m_pBuffers[index].pcBuffer, (request_rec*)m_pContext);
/* Let Axis know that the buffer is no longer in use */
m_pReleaseBufferCallback(m_pBuffers[index].pcBuffer,
m_pBuffers[index].pBufferId);
}
}
#endif
return TRANSPORT_FINISHED;
}
AXIS_TRANSPORT_STATUS Apache2Transport::getBytes(char* pBuffer, int* piSize)
{
int nBufSize = *piSize;
int len_read;
len_read = ap_get_client_block((request_rec*) m_pContext, pBuffer, *piSize);
*piSize = len_read;
if (len_read < nBufSize)
{
pBuffer[len_read] = '\0';
return TRANSPORT_FINISHED;
}
else
return TRANSPORT_IN_PROGRESS;
}
const char* Apache2Transport::getTransportProperty(AXIS_TRANSPORT_INFORMATION_TYPE eType)
{
const char* pcValue;
/* the member, "path" of "parsed_uri" contains the uri of the
request (i.e "/abc/xyz" part of http://somehost/abc/xyz) */
const char* pcUriPath = ((request_rec*)m_pContext)->parsed_uri.path;
switch (eType)
{
case SOAPACTION_HEADER:
return getTransportProperty("SOAPAction");
case SERVICE_URI:
if (strstr(pcUriPath, AXIS_URI_EXTENSION))
{
return strstr(pcUriPath, AXIS_URI_EXTENSION) +
strlen(AXIS_URI_EXTENSION) + 1;
}
else
{
return pcUriPath;
}
case OPERATION_NAME:
pcValue = getTransportProperty("SOAPAction");
if (pcValue)
{
if (strstr(pcValue, SOAPACTION_METHODNAME_SEPARATOR))
{
return strstr(pcValue, SOAPACTION_METHODNAME_SEPARATOR) +
strlen(SOAPACTION_METHODNAME_SEPARATOR);
}
else
{
return pcValue;
}
}
case SOAP_MESSAGE_LENGTH:
return getTransportProperty("Content-Length");
/* this is apache module and transport is http so the key */
default:;
}
return NULL;
}
void Apache2Transport::setTransportProperty(const char* pcKey, const char* pcValue)
{
}
const char* Apache2Transport::getTransportProperty(const char* pcKey)
{
/* ap_table_elts returns an array_header struct. The nelts element of that
* struct contains the number of input header elements. Finally assigns that
* to the axis soap data structure. */
const apr_array_header_t* arr;
int headercount = ap_table_elts(((request_rec*)m_pContext)->headers_in)->nelts;
apr_table_entry_t* pHeaders = 0;
/* casting req_rec->headers_in to axis header struct and assigning that to
* the axis soap structure. Hope this is ok
*/
/* obtain the array_header from the headers_in table and assign it to the
* axis soap structure
*/
arr = ap_table_elts(((request_rec*)m_pContext)->headers_in);
pHeaders = (apr_table_entry_t*)arr->elts;
for (int ix=0; ix<headercount; ix++)
{
if (!strcmp(pHeaders->key, pcKey))
return pHeaders->val;
pHeaders++;
}
return 0;
}
void Apache2Transport::setSessionId(const char* pcSessionId)
{
}
const char* Apache2Transport::getSessionId()
{
return "this is temporary session id"; //TODO
}
const char* Apache2Transport::getServiceName()
{
return 0; //TODO
}
AXIS_PROTOCOL_TYPE Apache2Transport::getProtocol()
{
return APTHTTP;
}
int Apache2Transport::getSubProtocol()
{
/*Determine the http method and assign it to the axis soap structure */
switch (((request_rec*)m_pContext)->method_number)
{
case M_GET:
return AXIS_HTTP_GET;
case M_POST:
return AXIS_HTTP_POST;
default:
return AXIS_HTTP_UNSUPPORTED;
}
}
1.1 ws-axis/c/src/server/apache2/Apache2Transport.h
Index: Apache2Transport.h
===================================================================
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* @author Susantha Kumara (susantha@opensource.lk, skumara@virtusa.com)
*
*/
#if !defined(AXIS_APACHE2TRANSPORT_H__OF_AXIS_INCLUDED_)
#define AXIS_APACHE2TRANSPORT_H__OF_AXIS_INCLUDED_
#include <apache2_0/httpd.h>
#include <apache2_0/http_config.h>
#include <apache2_0/http_core.h>
#include <apache2_0/http_protocol.h>
#include <apache2_0/http_log.h>
#include <apache2_0/ap_compat.h>
#include <apache2_0/apr_tables.h>
#include <axis/SOAPTransport.h>
#include <string.h>
class Apache2Transport : public SOAPTransport
{
public:
Apache2Transport(void* pContext);
virtual ~Apache2Transport();
int openConnection(){return AXIS_SUCCESS;};
void closeConnection(){};
AXIS_TRANSPORT_STATUS sendBytes(const char* pcSendBuffer, const void* pBufferId);
void registerReleaseBufferCallback(AXIS_ENGINE_CALLBACK_RELEASE_SEND_BUFFER pFunct)
{ m_pReleaseBufferCallback = pFunct; };
AXIS_TRANSPORT_STATUS getBytes(char* pBuffer, int* piSize);
void releaseBuffer(const char* pBuffer);
void setTransportProperty(AXIS_TRANSPORT_INFORMATION_TYPE type, const char* value);
const char* getTransportProperty(AXIS_TRANSPORT_INFORMATION_TYPE eType);
void setTransportProperty(const char* pcKey, const char* pcValue);
const char* getTransportProperty(const char* pcKey);
void setAttachment(const char* pcAttachmentid, const char* pcAttachment){};
const char* getAttachment(const char* pcAttachmentid){return "value";};
void setEndpointUri(const char* pcEndpointUri)
{m_pcEndpointUri = strdup(pcEndpointUri);};
void setSessionId(const char* pcSessionId);
const char* getSessionId();
const char* getServiceName();
AXIS_PROTOCOL_TYPE getProtocol();
int getSubProtocol();
AXIS_TRANSPORT_STATUS flushOutput();
private:
void* m_pContext;
#ifndef CHUNCKED_DATA_SUPPORTED
BufferInfo* m_pBuffers;
#endif
};
#endif
1.1 ws-axis/c/src/server/apache2/mod_axis2.cpp
Index: mod_axis2.cpp
===================================================================
/* -*- C++ -*- */
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "Apache2Transport.h"
#define xxx ap_log_rerror(APLOG_MARK,APLOG_ERR, globr,"logged here");
#define yyy ap_log_rerror(APLOG_MARK, APLOG_ERR, globr,"logged here");
/* file: mod_axis2.cpp */
/* here's the content handler */
extern int process_request(SOAPTransport* str);
extern unsigned char chEBuf[1024];
int axis_handler_helper(request_rec* req_rec)
{
int rc;
SOAPTransport* pTransport;
if ((!req_rec->handler) || strcmp(req_rec->handler, "axis") != 0)
{
return DECLINED;
}
pTransport = new Apache2Transport((void*)req_rec);
/* for SOAP 1.2 this this should be "application/soap+xml" but keep this for
* the moment. */
req_rec->content_type = (M_POST == req_rec->method_number) ?
"text/xml" : "text/html";
/* Set up the read policy from the client.*/
if ((rc = ap_setup_client_block(req_rec, REQUEST_CHUNKED_ERROR)) != OK)
{
delete pTransport;
return rc;
}
/* Tell the client that we are ready to receive content and check whether
* client will send content. control will pass to this block only if there is
* body content in the request
*/
if (ap_should_client_block(req_rec));
if (0 != process_request(pTransport))
{
delete pTransport;
return OK;
}
delete pTransport;
return OK;
}
/* Call initialize_module() [of Packet.h] from within this method */
extern "C"
{
static void module_init(apr_pool_t* p, server_rec* svr_rec)
{
initialize_module(1);
}
/* Call initialize_process() [of Packet.h] from within this method */
static void axis_Init(server_rec* svr_rec, apr_pool_t* p)
{
}
/*Call finalize_process() [of Packet.h] from within this method*/
static void axis_Fini(server_rec* svr_rec, apr_pool_t* p)
{
}
static int axis_handler(request_rec* req_rec)
{
return axis_handler_helper(req_rec);
}
static void mod_axis_register_hooks(apr_pool_t* p)
{
ap_hook_child_init(module_init, NULL, NULL, APR_HOOK_REALLY_FIRST);
/* ap_hook_pre_connection(axis_Init, NULL, NULL, APR_HOOK_FIRST); */
ap_hook_handler(axis_handler, NULL, NULL, APR_HOOK_LAST);
/* ap_hook_process_connection(axis_Fini, NULL, NULL, APR_HOOK_REALLY_LAST);
*/
}
module AP_MODULE_DECLARE_DATA axis_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
mod_axis_register_hooks,
};
}
1.2 +5 -1 ws-axis/c/src/xml/xerces/SoapParserXerces.cpp
Index: SoapParserXerces.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/xml/xerces/SoapParserXerces.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SoapParserXerces.cpp 18 May 2004 11:09:10 -0000 1.1
+++ SoapParserXerces.cpp 24 May 2004 05:54:55 -0000 1.2
@@ -86,8 +86,12 @@
m_Xhandler.freeElement();
while (true)
{
- bCanParseMore = m_pParser->parseNext(m_ScanToken);
AnyElement* elem = m_Xhandler.getAnyElement();
+ if (!elem)
+ {
+ bCanParseMore = m_pParser->parseNext(m_ScanToken);
+ elem = m_Xhandler.getAnyElement();
+ }
if (elem)
{
if (!isCharData && (CHARACTER_ELEMENT == elem->m_type))
1.2 +20 -2 ws-axis/c/src/xml/xerces/XercesHandler.cpp
Index: XercesHandler.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/xml/xerces/XercesHandler.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XercesHandler.cpp 18 May 2004 11:09:10 -0000 1.1
+++ XercesHandler.cpp 24 May 2004 05:54:55 -0000 1.2
@@ -30,6 +30,7 @@
{
m_nStatus = AXIS_SUCCESS;
Nelement = (AnyElement*)malloc(sizeof (AnyElement));
+ m_bEndElementFollows = false;
}
XercesHandler::~XercesHandler()
@@ -99,6 +100,13 @@
const XMLCh *const localname,
const XMLCh *const qname)
{
+ if (m_pCurrElement && (START_ELEMENT == m_pCurrElement->m_type))
+ /* it seems that both startElement and endElemen events fired within a
+ single parseNext call */
+ {
+ m_bEndElementFollows = true;
+ return;
+ }
m_pCurrElement = Nelement;
Nelement->m_type = END_ELEMENT;
Nelement->m_pchNameOrValue = XMLString::transcode(localname);
@@ -126,7 +134,17 @@
{
if (m_pCurrElement)
{
- /* free inner variables */
- m_pCurrElement = 0;
+ if (m_bEndElementFollows)
+ /* free only attributes list if available */
+ {
+ m_bEndElementFollows = false;
+ Nelement->m_type = END_ELEMENT;
+ Nelement->m_pchAttributes[0] = NULL;
+ }
+ else
+ /* free all inner strings */
+ {
+ m_pCurrElement = 0;
+ }
}
}
1.2 +1 -0 ws-axis/c/src/xml/xerces/XercesHandler.h
Index: XercesHandler.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/xml/xerces/XercesHandler.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XercesHandler.h 18 May 2004 11:09:10 -0000 1.1
+++ XercesHandler.h 24 May 2004 05:54:55 -0000 1.2
@@ -77,6 +77,7 @@
void fatalError(const SAXParseException& exception);
int m_nStatus;
+ bool m_bEndElementFollows;
AnyElement * Nelement;
AnyElement * m_pCurrElement;
1.8 +9 -1 ws-axis/c/vc/server/apache2_0/Apache2_0Module.dsp
Index: Apache2_0Module.dsp
===================================================================
RCS file: /home/cvs/ws-axis/c/vc/server/apache2_0/Apache2_0Module.dsp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Apache2_0Module.dsp 18 May 2004 11:09:11 -0000 1.7
+++ Apache2_0Module.dsp 24 May 2004 05:54:55 -0000 1.8
@@ -92,12 +92,20 @@
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
-SOURCE=..\..\..\src\server\apache2\mod_axis2.c
+SOURCE=..\..\..\src\server\apache2\Apache2Transport.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\src\server\apache2\mod_axis2.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\src\server\apache2\Apache2Transport.h
+# End Source File
# End Group
# Begin Group "Resource Files"