axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanj...@apache.org
Subject cvs commit: ws-axis/c/src/soap SoapBinInputStream.cpp SoapParserXerces.cpp SoapParserXerces.h XercesHandler.cpp XercesHandler.h
Date Thu, 01 Apr 2004 13:56:42 GMT
sanjaya     2004/04/01 05:56:42

  Modified:    c/src/server/apache mod_axis.c
               c/src/server/apache2 mod_axis2.c
               c/src/soap SoapBinInputStream.cpp SoapParserXerces.cpp
                        SoapParserXerces.h XercesHandler.cpp
                        XercesHandler.h
  Log:
  -changes to the apache modules to accomodate the xerces parser
  -changes to xerces parsing of deserialization
  
  Revision  Changes    Path
  1.24      +28 -2     ws-axis/c/src/server/apache/mod_axis.c
  
  Index: mod_axis.c
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/server/apache/mod_axis.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- mod_axis.c	24 Mar 2004 06:57:32 -0000	1.23
  +++ mod_axis.c	1 Apr 2004 13:56:42 -0000	1.24
  @@ -27,8 +27,8 @@
   /*extern int process(soapstream *);*/
   extern unsigned char chEBuf[1024];
   
  -#define SIZEOFMODULEBUFFER 4096
  -
  +//#define SIZEOFMODULEBUFFER 4096
  +#define SIZEOFMODULEBUFFER 32
   
   /**
    * This method adds the http header to the Ax_soapstream. These headers will be dispatched
later
  @@ -118,6 +118,23 @@
    */
   static AXIS_TRANSPORT_STATUS AXISCALL get_request_bytes(const char** req, int* retsize,
const Ax_soapstream* stream)
   {
  +#ifdef USE_XERCES_PARSER
  +	int nBufSize = *retsize;
  +	int len_read;
  +	char* pBuffer = *req;
  +	if (!(*req)) return TRANSPORT_FAILED;
  +	ap_hard_timeout("util_read", (request_rec*)stream->str.ip_stream);
  +	len_read = ap_get_client_block((request_rec*)stream->str.ip_stream, *req, nBufSize);
  +	ap_reset_timeout((request_rec*)stream->str.ip_stream);
  +	*retsize =  len_read;
  +	if (len_read < nBufSize)
  +	{
  +		pBuffer[len_read] = '\0';
  +		return TRANSPORT_FINISHED;
  +	}
  +	else
  +		return TRANSPORT_IN_PROGRESS;
  +#else
   	 /*How can I detect an error when reading stream ? Sanjaya ?
   	 In case of an error set buffer to null, size 0 and return TRANSPORT_FAILED*/
   	int len_read;
  @@ -135,6 +152,7 @@
   	}
   	else
   		return TRANSPORT_IN_PROGRESS;
  +#endif
   }
   
   static void AXISCALL release_receive_buffer(const char* buffer, const Ax_soapstream* stream)
  @@ -211,14 +229,18 @@
   	sstr->reserved2 = NULL;
   #else
   	sstr->reserved1 = calloc(NO_OF_SERIALIZE_BUFFERS, sizeof(sendbuffers));
  +#ifdef USE_EXPAT_PARSER
   	sstr->reserved2 = malloc(SIZEOFMODULEBUFFER);
   #endif
  +#endif
   	req_rec->content_type = "text/xml"; /*for SOAP 1.2 this this should be "application/soap+xml"
but keep this for the moment*/
   	/*set up the read policy from the client.*/
   	if ((rc = ap_setup_client_block(req_rec, REQUEST_CHUNKED_ERROR)) != OK)
   	{
   		if (sstr->reserved1) free(sstr->reserved1);
  +#ifdef USE_EXPAT_PARSER
   		if (sstr->reserved2) free(sstr->reserved2);
  +#endif
   		free(sstr->so.http);
   		free(sstr);
   		return rc;
  @@ -258,7 +280,9 @@
   	if(0 != process_request(sstr))
   	{
   		if (sstr->reserved1) free(sstr->reserved1);
  +#ifdef USE_EXPAT_PARSER
   		if (sstr->reserved2) free(sstr->reserved2);
  +#endif
   		free(sstr->so.http);
   		free(sstr);
   		return OK;
  @@ -292,7 +316,9 @@
   	}
   	/*Free the array */
   	if (sstr->reserved1) free(sstr->reserved1);
  +#ifdef USE_EXPAT_PARSER
   	if (sstr->reserved2) free(sstr->reserved2);
  +#endif
   
   #endif
   	free(sstr->so.http);
  
  
  
  1.8       +30 -2     ws-axis/c/src/server/apache2/mod_axis2.c
  
  Index: mod_axis2.c
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/server/apache2/mod_axis2.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- mod_axis2.c	24 Mar 2004 06:57:32 -0000	1.7
  +++ mod_axis2.c	1 Apr 2004 13:56:42 -0000	1.8
  @@ -182,14 +182,31 @@
    */
   static AXIS_TRANSPORT_STATUS AXISCALL get_request_bytes(const char** req, int* retsize,
const Ax_soapstream* stream)
   {
  +#ifdef USE_XERCES_PARSER
  +	int nBufSize = *retsize;
  +	int len_read;
  +	char* pBuffer = *req;
  +	if (!(*req)) return TRANSPORT_FAILED;
  +	/* ap_hard_timeout("util_read", (request_rec*)stream->str.ip_stream); */
  +	len_read = ap_get_client_block((request_rec*)stream->str.ip_stream, *req, nBufSize);
  +	/* ap_reset_timeout((request_rec*)stream->str.ip_stream); */
  +	*retsize =  len_read;
  +	if (len_read < nBufSize)
  +	{
  +		pBuffer[len_read] = '\0';
  +		return TRANSPORT_FINISHED;
  +	}
  +	else
  +		return TRANSPORT_IN_PROGRESS;
  +#else
   	 /*How can I detect an error when reading stream ? Sanjaya ?
   	 In case of an error set buffer to null, size 0 and return TRANSPORT_FAILED*/
   	int len_read;
   	char* pBuffer = stream->reserved2;
   	if (!pBuffer) return TRANSPORT_FAILED;
  -	/* ap_hard_timeout("util_read", (request_rec*)stream->str.ip_stream);*/
  +	/* ap_hard_timeout("util_read", (request_rec*)stream->str.ip_stream); */
   	len_read = ap_get_client_block((request_rec*)stream->str.ip_stream, pBuffer, SIZEOFMODULEBUFFER);
  -	/*ap_reset_timeout((request_rec*)stream->str.ip_stream);*/
  +	/* ap_reset_timeout((request_rec*)stream->str.ip_stream); */
   	*req = pBuffer;
   	*retsize =  len_read;
   	if (len_read < SIZEOFMODULEBUFFER)
  @@ -199,6 +216,7 @@
   	}
   	else
   		return TRANSPORT_IN_PROGRESS;
  +#endif
   }
   
   static void AXISCALL release_receive_buffer(const char* buffer, const Ax_soapstream* stream)
  @@ -286,14 +304,18 @@
   	sstr->reserved2 = NULL;
   #else
   	sstr->reserved1 = calloc(NO_OF_SERIALIZE_BUFFERS, sizeof(sendbuffers));
  +#ifdef USE_EXPAT_PARSER
   	sstr->reserved2 = malloc(SIZEOFMODULEBUFFER);
   #endif
  +#endif
   
   	/*set up the read policy from the client.*/
   	if ((rc = ap_setup_client_block(req_rec, REQUEST_CHUNKED_ERROR)) != OK)
   	{
   		if (sstr->reserved1) free(sstr->reserved1); 
  +#ifdef USE_EXPAT_PARSER
           if (sstr->reserved2) free(sstr->reserved2); 
  +#endif
           free(sstr->so.http); 
           free(sstr); 
   
  @@ -346,7 +368,9 @@
   	if(0 != process_request(sstr))
   	{
   		if (sstr->reserved1) free(sstr->reserved1); 
  +#ifdef USE_EXPAT_PARSER
           if (sstr->reserved2) free(sstr->reserved2); 
  +#endif
           free(sstr->so.http); 
           free(sstr); 
   
  @@ -383,7 +407,11 @@
   	}
   	/*Free the array */
   	if (sstr->reserved1) free(sstr->reserved1);
  +
  +#ifdef USE_EXPAT_PARSER
   	if (sstr->reserved2) free(sstr->reserved2);
  +#endif
  +
   #endif
   
   	free(sstr);
  
  
  
  1.3       +2 -3      ws-axis/c/src/soap/SoapBinInputStream.cpp
  
  Index: SoapBinInputStream.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapBinInputStream.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SoapBinInputStream.cpp	31 Mar 2004 12:20:03 -0000	1.2
  +++ SoapBinInputStream.cpp	1 Apr 2004 13:56:42 -0000	1.3
  @@ -47,8 +47,7 @@
   
   unsigned int SoapBinInputStream::readBytes(XMLByte* const toFill, const unsigned int maxToRead)
   {
  -	int nRead = 0;
  -	m_pReadFunct((const char**)toFill, (int*)&maxToRead, m_pContext);
  -    
  +	int nRead = maxToRead;
  +	m_pReadFunct((const char**)&toFill, (int*)&nRead, m_pContext);
   	return nRead;
   }
  
  
  
  1.2       +9 -6      ws-axis/c/src/soap/SoapParserXerces.cpp
  
  Index: SoapParserXerces.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapParserXerces.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SoapParserXerces.cpp	31 Mar 2004 12:20:02 -0000	1.1
  +++ SoapParserXerces.cpp	1 Apr 2004 13:56:42 -0000	1.2
  @@ -43,7 +43,7 @@
   int SoapParserXerces::SetInputStream(const Ax_soapstream* pInputStream)
   {
   	m_pInputStream = pInputStream;
  -	is = new SoapInputSource(m_pInputStream->transport.pGetFunct, m_pInputStream->str.ip_stream);
  +	is = new SoapInputSource(m_pInputStream->transport.pGetFunct, m_pInputStream);
   	//SoapInputSource is(m_pInputStream->transport.pGetFunct, m_pInputStream->str.ip_stream);
   	m_pParser->setContentHandler(&Xhandler);
   	//return m_pHandler->Success();
  @@ -75,9 +75,12 @@
   		firstParsed = true;
   	}
   
  -	m_pParser->parseNext(token);
  -
  -	return Xhandler.getAnyElement();
  -	//handler
  -	//return NULL;
  +	Xhandler.freeElement();
  +	while (true)
  +	{
  +		m_pParser->parseNext(token);
  +		AnyElement* elem = Xhandler.getAnyElement();
  +		if (elem) return elem;
  +		else if (AXIS_FAIL == Xhandler.GetStatus()) return NULL; 
  +	}
   }
  
  
  
  1.2       +1 -2      ws-axis/c/src/soap/SoapParserXerces.h
  
  Index: SoapParserXerces.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapParserXerces.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SoapParserXerces.h	31 Mar 2004 12:20:02 -0000	1.1
  +++ SoapParserXerces.h	1 Apr 2004 13:56:42 -0000	1.2
  @@ -58,13 +58,12 @@
   	void SetTransportStatus(AXIS_TRANSPORT_STATUS nStatus){ m_nTransportStatus = nStatus;};
   
   
  -
  +	const Ax_soapstream* m_pInputStream;
   
   private:
   	int m_nStatus;
   	SAX2XMLReader* m_pParser;
   	//SAXParser* m_pParser;
  -	const Ax_soapstream* m_pInputStream;
   	AXIS_TRANSPORT_STATUS m_nTransportStatus;
       XMLPScanToken token;
   	XercesHandler Xhandler;
  
  
  
  1.2       +22 -8     ws-axis/c/src/soap/XercesHandler.cpp
  
  Index: XercesHandler.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/XercesHandler.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XercesHandler.cpp	31 Mar 2004 12:20:02 -0000	1.1
  +++ XercesHandler.cpp	1 Apr 2004 13:56:42 -0000	1.2
  @@ -18,6 +18,9 @@
   /*
    *	@author sanjaya singharage (sanjayas@opensource.lk)
    */
  +#ifdef WIN32
  +#pragma warning (disable : 4786)
  +#endif
   
   #include "XercesHandler.h"
   #include <xercesc/sax2/Attributes.hpp>
  @@ -26,7 +29,7 @@
   
   XercesHandler::XercesHandler()
   {
  -	test = 0;
  +	m_nStatus = AXIS_SUCCESS;
   	Nelement = (AnyElement*)malloc(sizeof (AnyElement));
   }
   
  @@ -36,8 +39,7 @@
   
   void XercesHandler::startElement(const XMLCh *const uri,const XMLCh *const localname,const
XMLCh *const qname,const Attributes &attrs)
   {
  -	printf("%s", "in start element");
  -	test++;
  +	m_pCurrElement = Nelement;
   	Nelement->m_type = START_ELEMENT;
   	Nelement->m_pchNameOrValue = XMLString::transcode(localname);
   	Nelement->m_pchNamespace = XMLString::transcode(uri);
  @@ -51,7 +53,6 @@
   		nextattrindex += 3;
   	}
   	Nelement->m_pchAttributes[len*3]=NULL;
  -
   }
   
   const XML_Ch* XercesHandler::NS4Prefix(const XML_Ch* prefix)
  @@ -65,8 +66,7 @@
   
   void XercesHandler::characters(const XMLCh* const chars, const unsigned int length)
   {
  -	printf("%s", XMLString::transcode(chars));
  -	test++;
  +	m_pCurrElement = Nelement;
   	Nelement->m_type = CHARACTER_ELEMENT;
   	Nelement->m_pchNameOrValue = XMLString::transcode(chars);
   }
  @@ -79,12 +79,17 @@
   void XercesHandler::warning(const SAXParseException& exception)
   {}
   void XercesHandler::error(const SAXParseException& exception)
  -{}
  +{
  +	m_nStatus = AXIS_FAIL;
  +}
   void XercesHandler::fatalError(const SAXParseException& exception)
  -{}
  +{
  +	m_nStatus = AXIS_FAIL;
  +}
   
   void XercesHandler::endElement (const XMLCh *const uri,const XMLCh *const localname,const
XMLCh *const qname)
   {
  +	m_pCurrElement = Nelement;
   	Nelement->m_type = END_ELEMENT;
   	Nelement->m_pchNameOrValue = XMLString::transcode(localname);
   	Nelement->m_pchNamespace = XMLString::transcode(uri);
  @@ -104,4 +109,13 @@
   	Nelement->m_type = END_PREFIX;
   	Nelement->m_pchNameOrValue = XMLString::transcode(prefix);
   	m_NsStack.erase(XMLString::transcode(prefix));
  +}
  +
  +void XercesHandler::freeElement()
  +{
  +	if (m_pCurrElement)
  +	{
  +		//free inner variables
  +		m_pCurrElement = 0;
  +	}
   }
  
  
  
  1.2       +14 -14    ws-axis/c/src/soap/XercesHandler.h
  
  Index: XercesHandler.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/XercesHandler.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XercesHandler.h	31 Mar 2004 12:20:02 -0000	1.1
  +++ XercesHandler.h	1 Apr 2004 13:56:42 -0000	1.2
  @@ -34,6 +34,8 @@
   class XercesHandler : public XERCES_CPP_NAMESPACE::DefaultHandler
   {
   public :
  +	void freeElement();
  +	int GetStatus(){return m_nStatus;};
       // -----------------------------------------------------------------------
       //  Constructors
       // -----------------------------------------------------------------------
  @@ -41,6 +43,15 @@
       ~XercesHandler();
   
   
  +
  +	const XML_Ch* XercesHandler::NS4Prefix(const XML_Ch* prefix);
  +
  +	AnyElement* getAnyElement()
  +	{
  +		return m_pCurrElement;
  +	}
  +
  +private:
       // -----------------------------------------------------------------------
       //  Handlers for the SAX DocumentHandler interface
       // -----------------------------------------------------------------------
  @@ -60,21 +71,10 @@
       void error(const SAXParseException& exception);
       void fatalError(const SAXParseException& exception);
   
  -	const XML_Ch* XercesHandler::NS4Prefix(const XML_Ch* prefix);
  -
  -	int getTest()
  -	{
  -		return test;
  -	}
  -
  -	AnyElement* getAnyElement()
  -	{
  -		return Nelement;
  -	}
  -
  -private:
  -	int test;
  +	int m_nStatus;
   	AnyElement * Nelement;
  +	AnyElement * m_pCurrElement;
  +
   	map<AxisXMLString, AxisXMLString> m_NsStack;
   	void initAnyElement()
   	{
  
  
  

Mime
View raw message