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 da...@apache.org on 2004/01/12 14:43:32 UTC
cvs commit: ws-axis/c/src/wsdd Makefile.am
damitha 2004/01/12 05:43:32
Modified: c/include/axis/client/transport/axis HttpTransport.hpp
Receiver.hpp Transport.hpp
c/src Makefile.am
c/src/client/transport/axis Channel.cpp HttpTransport.cpp
Receiver.cpp
c/src/common Makefile.am
c/src/engine Makefile.am
c/src/wsdd Makefile.am
Log:
Revision Changes Path
1.5 +6 -0 ws-axis/c/include/axis/client/transport/axis/HttpTransport.hpp
Index: HttpTransport.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/include/axis/client/transport/axis/HttpTransport.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HttpTransport.hpp 12 Jan 2004 12:20:49 -0000 1.4
+++ HttpTransport.hpp 12 Jan 2004 13:43:32 -0000 1.5
@@ -115,6 +115,9 @@
/// Write a given payload by using HTTP transport as carrier
const Transport& operator << (const char* p_Payload);
+ int getBodyLength();
+ void setBodyLength(int bodyLength);
+ int getIsHttpHeader();
private:
/// Build a HTTP packet with a given payload & additional HTTP properties
@@ -145,6 +148,9 @@
private:
Channel m_Channel;
bool m_HttpBindDone;
+ int m_IsHttpHeader;
+ std::string m_sHeader;
+ int m_intBodyLength;
};
#endif //_AXIS_HTTPTRANSPORT_HPP
1.5 +4 -0 ws-axis/c/include/axis/client/transport/axis/Receiver.hpp
Index: Receiver.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/include/axis/client/transport/axis/Receiver.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Receiver.hpp 12 Jan 2004 12:20:49 -0000 1.4
+++ Receiver.hpp 12 Jan 2004 13:43:32 -0000 1.5
@@ -77,6 +77,7 @@
~Receiver();
const char* Recv() throw (AxisException);
+ int getBytesRead();
private:
const char* m_pMsg;
@@ -84,6 +85,9 @@
Transport *m_pTrChannel;
unsigned int m_RecvPort;
+
+ int m_MsgSize;
+ int m_BytesRead;
};
#endif // _AXIS_RECEIVER_HPP
1.5 +3 -0 ws-axis/c/include/axis/client/transport/axis/Transport.hpp
Index: Transport.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/include/axis/client/transport/axis/Transport.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Transport.hpp 12 Jan 2004 12:20:49 -0000 1.4
+++ Transport.hpp 12 Jan 2004 13:43:32 -0000 1.5
@@ -94,6 +94,9 @@
virtual const Transport& operator >> (const char** pMsg){*pMsg=NULL;return *this;}
virtual const Transport& operator << (const char* msg)=0;
virtual void ClearAdditionalHeaders(){};
+ virtual int getBodyLength() = 0;
+ virtual void setBodyLength(int bodyLength) = 0;
+ virtual int getIsHttpHeader() = 0;
protected:
1.5 +1 -1 ws-axis/c/src/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/ws-axis/c/src/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Makefile.am 12 Jan 2004 12:20:51 -0000 1.4
+++ Makefile.am 12 Jan 2004 13:43:32 -0000 1.5
@@ -1,6 +1,6 @@
lib_LTLIBRARIES = libaxiscpp_mod.la
SUBDIRS = common engine server soap wsdd xml
-AM_CPPFLAGS = -Wall
+AM_CPPFLAGS = -Wall -DUSE_EXPAT_PARSER
libaxiscpp_mod_la_SOURCES =
libaxiscpp_mod_la_LIBADD = ./common/libcommon.la ./engine/libengine.la ./server/apache/libapache.la ./soap/libsoap.la ./wsdd/libwsdd.la ./xml/libxml.la -L$(AXISCPP_HOME)/lib/expat -lexpat -ldl -lstdc++
1.5 +28 -32 ws-axis/c/src/client/transport/axis/Channel.cpp
Index: Channel.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/transport/axis/Channel.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Channel.cpp 12 Jan 2004 12:20:52 -0000 1.4
+++ Channel.cpp 12 Jan 2004 13:43:32 -0000 1.5
@@ -234,42 +234,38 @@
const Channel& Channel::operator >> (std::string& msg)
{
- msg = "";
- if(INVALID_SOCKET == m_Sock)
- {
- Error("Reading cannot be done without having a open socket.");
- throw ChannelException("Input streaming error on undefined channel; please open the channel first");
- }
+ msg = "";
+ if(INVALID_SOCKET == m_Sock)
+ {
+ Error("Reading cannot be done without having a open socket.");
+ throw ChannelException("Input streaming error on undefined channel; please open the channel first");
+ }
- int nByteRecv = 0;
- const int BUF_SIZE = 4096;
- char buf[BUF_SIZE];
-
- do // Manage multiple chuncks of the message
- {
- if ((nByteRecv = recv(m_Sock, (char *) &buf, BUF_SIZE - 1, 0)) == SOCKET_ERROR)
- {
- Error("Channel error while getting data.");
- CloseChannel();
- throw ChannelException("Input streaming error on Channel while getting data");
- }
+ int nByteRecv = 0;
+ const int BUF_SIZE = 512;
+ char buf[BUF_SIZE];
- if(nByteRecv)
- {
- buf[nByteRecv + 1] = '\0'; // got a part of the message, so add it to form
- msg += buf; // the whole message
+ if ((nByteRecv = recv(m_Sock, (char *) &buf, BUF_SIZE - 1, 0)) == SOCKET_ERROR)
+ {
+ perror("recv SOCKET_ERROR");
+ Error("Channel error while getting data.");
+ //CloseChannel();
+ return *this;
+ //throw ChannelException("Input streaming error on Channel while getting data");
+ }
+ if(nByteRecv)
+ {
+ //printf("if(nByteRecv)\n");
+ buf[nByteRecv] = '\0'; // got a part of the message, so add it to form
+ msg = buf;
+ //printf("buf:%s\n", buf);
+ }
+ else
+ printf("execution break\n");
- //Validate according to the transport; check whether we are in a position to return.
- if (!m_pTransportHandler->GetStatus(msg))
- break;
- }
- else
- break; // we have the whole message or an error has occured
- }
- while (true);
-
- return *this;
+ return *this;
}
+
/**
* Close, and clean-up any OS specific stuff
1.10 +170 -110 ws-axis/c/src/client/transport/axis/HttpTransport.cpp
Index: HttpTransport.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/transport/axis/HttpTransport.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HttpTransport.cpp 12 Jan 2004 12:20:52 -0000 1.9
+++ HttpTransport.cpp 12 Jan 2004 13:43:32 -0000 1.10
@@ -137,30 +137,64 @@
const Transport& HttpTransport::operator >> (const char** pPayLoad)
{
- if(!m_bStatus)
- {
- // We have the payload; this is due to Fault request made in earlier call
- // to this method
- *pPayLoad = m_PayLoad.c_str();
- return *this;
- }
+ if(!m_bStatus)
+ {
+ // We have the payload; this is due to Fault request made in earlier call
+ // to this method
+ *pPayLoad = m_PayLoad.c_str();
+
+ return *this;
+ }
+
+ std::string tmpPacket; // use temporary, need to workout for this
+ if(m_IsHttpHeader == 1)
+ {
+ //printf("m_IsHttpHeader == 1\n");
+ m_Channel >> tmpPacket;
+ *pPayLoad = tmpPacket.c_str();
+
+ return *this;
+ }
+ //printf("tmpPacket:%s\n", tmpPacket.c_str());
- std::string tmpPacket; // use temporary, need to workout for this
- m_Channel >> tmpPacket;
-
#ifdef _DEBUG
- std::cout << "\n\n\nGot the message:\r\n\r\n" << tmpPacket << "\n\n";
+ std::cout << "\n\n\nGot the message:\r\n\r\n" << tmpPacket << "\n\n";
#endif
-
- // Validate the HTTP packet
- if(!m_bStatus) HTTPValidate(tmpPacket);
+ do //process will step into this only if http validation is not done. That is, until the stream
+ //contain the httpd header.
+ {
+ m_Channel >> tmpPacket;
+
+ // Validate the HTTP packet
+ if(m_IsHttpHeader == 1) //if header is validated but payload has zero length, process will steop into this.
+ {
+ //printf("while,m_IsHttpHeader == 1\n");
+ *pPayLoad = tmpPacket.c_str();
+
+ break;
+ }
+ //printf("do while\n");
+ if(m_bStatus) HTTPValidate(tmpPacket); //Validate the header
+ int j = strlen(tmpPacket.c_str());
+ if(j == 0)
+ break;
+ *pPayLoad = m_PayLoad.c_str();
+ int i = strlen(m_PayLoad.c_str());
+ //printf("i:%d\n", i);
+ //If payload has nonzero length
+ if(i > 0)
+ {
+ //printf("if i> 0\n");
+ break;
+ }
+ } while(true);
- // At this point we have the payload at hand so give it out
- *pPayLoad = m_PayLoad.c_str();
- return *this;
+
+ return *this;
}
+
/**
* Write a given payload to the established channel by using HTTP transport as carrier.
*
@@ -257,66 +291,74 @@
void HttpTransport::HTTPValidate(const std::string& p_HttpPacket)
{
- // for the time being just get the payload. Here we need much work
+ // for the time being just get the payload. Here we need much work
- m_bStatus = true;
- std::string::size_type pos = p_HttpPacket.find('\n'), nxtpos;
+ m_bStatus = true;
+ int nHttpSatus;
- int nHttpSatus;
+ m_sHeader += p_HttpPacket;
- if(pos == std::string::npos) return; //unexpected string
-
- std::string strLine = p_HttpPacket.substr(0, pos + 1);
- std::string::size_type offset = pos + 1;
-
- // Check for HTTP header validity; HTTP 1.0 / HTTP 1.0 is supported.
- if((pos = strLine.find("HTTP/1.0")) != std::string::npos
- || (pos = strLine.find("HTTP/1.1")) != std::string::npos)
- {
- if(((pos = strLine.find_first_of("\" ", pos + strlen("HTTP/1.x")))
- != std::string::npos) &&
- (nxtpos = strLine.find_first_of("\" ", pos)) != std::string::npos)
- {
- pos++;
- // Get the HTTP status code of the packet obtained
- nHttpSatus = atoi(strLine.substr(pos, nxtpos - pos).c_str())/100;
- }
- else
- return;
-
-
- // Status code is 2xx; so valid packet. hence go ahead and extract the payload.
- if(nHttpSatus == 2)
- {
- GetPayLoad(p_HttpPacket, offset);
- }
- else if(nHttpSatus == 3) // Status code is 3xx; some error has occurred
- {
- // error recovery mechanism should go here
- Error(p_HttpPacket.c_str());
- throw ChannelException("HTTP Error, cannot process response message...");
- }
- else if(nHttpSatus == 4) // Status code is 4xx; some error has occurred
- {
- // error recovery mechanism should go here
- Error(p_HttpPacket.c_str());
- throw ChannelException("HTTP Error, cannot process response message...");
- }
- else if(nHttpSatus == 5) // Status code is 5xx; some error has occurred
- {
- // error recovery mechanism should go here
- GetPayLoad(p_HttpPacket, offset);
- if (!m_bStatus)
- {
- Error(p_HttpPacket.c_str());
- throw AxisException(HTTP_ERROR);
- }
- }
- }
- else
- throw ChannelException("Unknow HTTP response, cannot process response message...");
+ //printf("m_sHeader:%s\n", m_sHeader.c_str());
+ std::string::size_type pos, nxtpos;
+ pos = p_HttpPacket.find("\r\n\r\n");
+ if(pos == std::string::npos)
+ {
+ m_PayLoad = "";
+ return; //unexpected string
+ }
+
+ m_IsHttpHeader = 1; //We have the stream until payload
+ pos = m_sHeader.find('\n');
+ std::string strLine = m_sHeader.substr(0, pos + 1);
+ std::string::size_type offset = pos + 1;
+ // Check for HTTP header validity; HTTP 1.0 / HTTP 1.0 is supported.
+ if((pos = strLine.find("HTTP/1.0")) != std::string::npos
+ || (pos = strLine.find("HTTP/1.1")) != std::string::npos)
+ {
+ if(((pos = strLine.find_first_of("\" ", pos + strlen("HTTP/1.x")))
+ != std::string::npos) &&
+ (nxtpos = strLine.find_first_of("\" ", pos)) != std::string::npos)
+ {
+ pos++;
+ // Get the HTTP status code of the packet obtained
+ nHttpSatus = atoi(strLine.substr(pos, nxtpos - pos).c_str())/100;
+ }
+ else
+ return;
+
+
+ // Status code is 2xx; so valid packet. hence go ahead and extract the payload.
+ if(nHttpSatus == 2)
+ {
+ //printf("nHttpSatus is 2\n");
+ GetPayLoad(m_sHeader, offset);
+ }
+ else if(nHttpSatus == 3) // Status code is 3xx; some error has occurred
+ {
+ // error recovery mechanism should go here
+ Error(m_sHeader.c_str());
+ throw ChannelException("HTTP Error, cannot process response message..."); }
+ else if(nHttpSatus == 4) // Status code is 4xx; some error has occurred
+ {
+ // error recovery mechanism should go here
+ Error(m_sHeader.c_str());
+ throw ChannelException("HTTP Error, cannot process response message..."); }
+ else if(nHttpSatus == 5) // Status code is 5xx; some error has occurred
+ {
+ // error recovery mechanism should go here
+ GetPayLoad(m_sHeader, offset);
+ if (!m_bStatus)
+ {
+ Error(m_sHeader.c_str());
+ throw AxisException(HTTP_ERROR);
+ }
+ }
+ }
+ else
+ throw ChannelException("Unknow HTTP response, cannot process response message...");
}
+
/**
@@ -326,47 +368,49 @@
void HttpTransport::GetPayLoad(const std::string& p_HttpPacket, std::string::size_type& offset)
{
- std::string::size_type pos, nxtpos;
- std::string strLine;
- int len=0;
-
- // process rest of the HTTP packet
- while (true)
- {
- if((nxtpos = p_HttpPacket.find('\n', offset)) == std::string::npos) return;
- nxtpos++;
- strLine = p_HttpPacket.substr(offset, nxtpos - offset);
- offset = nxtpos;
-
- if((strLine == "\r\n") || (strLine == "\n") || strLine.size() <= 1)
- break;
-
- // Get the payload size from the header.
- if((pos = strLine.find("Content-Length:")) != std::string::npos)
- len = atoi(strLine.substr(pos + strlen("Content-Length: ")).c_str());
- }
-
- m_PayLoad = p_HttpPacket.substr(offset);
-
- pos = m_PayLoad.rfind('0');
-
- if(std::string::npos != pos && m_PayLoad[pos+1] != '\"')
- {
- //nxtpos = m_PayLoad.find("1df");
- //if(std::string::npos != nxtpos && '\n' == m_PayLoad[nxtpos+4])
- {
- m_bStatus = false; // we have the payload
- // Extract the SOAP message
- m_PayLoad = m_PayLoad.substr(m_PayLoad.find('<'));
- m_PayLoad = m_PayLoad.substr(0, m_PayLoad.rfind('>') + 1);
- }
- }
+ std::string::size_type pos, nxtpos;
+ std::string strLine;
+ //int len=0;
+
+ // process rest of the HTTP packet
+ while (true)
+ {
+ if((nxtpos = p_HttpPacket.find('\n', offset)) == std::string::npos) return;
+ nxtpos++;
+ strLine = p_HttpPacket.substr(offset, nxtpos - offset);
+ offset = nxtpos;
+
+ if((strLine == "\r\n") || (strLine == "\n") || strLine.size() <= 1)
+ break;
+
+ // Get the payload size from the header.
+ if((pos = strLine.find("Content-Length:")) != std::string::npos)
+ m_intBodyLength = atoi(strLine.substr(pos + strlen("Content-Length: ")).c_str());
+ //printf("m_intBodyLength:%d\n", m_intBodyLength);
+ }
+
+ m_PayLoad = p_HttpPacket.substr(offset);
+ //printf("m_PayLoad:%s\n", m_PayLoad.c_str());
+
+
+ //pos = m_PayLoad.rfind('0');
+
+ //if(std::string::npos != pos && m_PayLoad[pos+1] != '\"')
+ //{
+ //nxtpos = m_PayLoad.find("1df");
+ //if(std::string::npos != nxtpos && '\n' == m_PayLoad[nxtpos+4])
+ //{
+ //m_bStatus = false; // we have the payload
+ // Extract the SOAP message
+ //m_PayLoad = m_PayLoad.substr(m_PayLoad.find('<'));
+ //m_PayLoad = m_PayLoad.substr(0, m_PayLoad.rfind('>') + 1);
+ //}
+ //}
#ifdef _DEBUG
- std::cout << "Payload:\n" << m_PayLoad << std::endl;
+ std::cout << "Payload:\n" << m_PayLoad << std::endl;
#endif
-
-}
+}
/**
@@ -384,4 +428,20 @@
void HttpTransport::ClearAdditionalHeaders()
{
m_AdditionalHeader.clear();
+}
+
+int HttpTransport::getBodyLength()
+{
+ return m_intBodyLength;
+}
+
+void HttpTransport::setBodyLength(int bodyLength)
+{
+ m_intBodyLength = bodyLength;
+
+}
+
+int HttpTransport::getIsHttpHeader()
+{
+ return m_IsHttpHeader;
}
1.7 +59 -12 ws-axis/c/src/client/transport/axis/Receiver.cpp
Index: Receiver.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/transport/axis/Receiver.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Receiver.cpp 12 Jan 2004 12:20:52 -0000 1.6
+++ Receiver.cpp 12 Jan 2004 13:43:32 -0000 1.7
@@ -59,11 +59,13 @@
*
*
* @author Lilantha Darshana (lilantha@virtusa.com)
+ * @author Damitha Kumarage (damitha@jkcsworld.com, damitha@opensource.lk)
*
*/
#include <axis/client/transport/axis/Platform.hpp>
#include <axis/client/transport/axis/Receiver.hpp>
+#include <axis/client/transport/axis/HttpTransport.hpp>
#include <iostream>
@@ -74,23 +76,68 @@
const char* Receiver::Recv() throw (AxisException)
{
- if (m_pMsg) return NULL; //this has been read earlier.
- try
+ int bodyLength;
+ int isHttpHeader;
+ const char* pToReturn = NULL;
+ isHttpHeader = m_pTrChannel->getIsHttpHeader();
+ bodyLength = m_pTrChannel->getBodyLength();
+ //printf("bodyLength:%d\n", bodyLength);
+ //printf("isHttpHeader:%d\n", isHttpHeader);
+ if(isHttpHeader == 1 && bodyLength == 0)
+ return NULL;
+ if (0 == m_BytesRead)
{
- *m_pTrChannel >> (&m_pMsg);
+ try
+ {
+ //printf("try\n");
+ *m_pTrChannel >> (&m_pMsg);
+ if(m_pMsg == NULL)
+ return NULL;
+
+ m_MsgSize = strlen(m_pMsg);
+ }
+ catch(AxisException& ex)
+ {
+ printf("catch\n");
+ // Get the fault message.
+ *m_pTrChannel >> (&m_pMsg);
+ m_MsgSize = strlen(m_pMsg);
+ #ifdef _DEBUG
+ // std::cerr << ex.GetErrorMsg() << std::endl;
+ #endif
+ }
+ catch(...)
+ {
+ printf("catch(...)\n");
+ throw AxisException(RECEPTION_ERROR);
+ }
}
- catch(AxisException& ex)
+ //printf("m_MsgSize:%d\n", m_MsgSize);
+ if (m_MsgSize > 0)
{
- // Get the fault message.
- *m_pTrChannel >> (&m_pMsg);
- #ifdef _DEBUG
- // std::cerr << ex.GetErrorMsg() << std::endl;
- #endif
+ bodyLength = m_pTrChannel->getBodyLength();
+ //printf("m_MsgSize:%d\n", m_MsgSize);
+ //printf("bodyLength:%d\n", bodyLength);
+ bodyLength -= m_MsgSize;
+ m_pTrChannel->setBodyLength(bodyLength);
+ pToReturn = m_pMsg;
+ m_BytesRead = m_MsgSize;
+ //printf("m_BytesRead:%d\n", m_BytesRead);
+ m_MsgSize -= m_BytesRead;
+ m_pMsg += m_BytesRead;
+ m_BytesRead = 0;
+
+ return pToReturn;
}
- catch(...)
+ else
{
- throw AxisException(RECEPTION_ERROR);
+ printf("m_MsgSize == 0, so return NULL\n");
+ return NULL;
}
- return m_pMsg;
+}
+
+int Receiver::getBytesRead()
+{
+ return m_BytesRead;
}
1.12 +1 -1 ws-axis/c/src/common/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Makefile.am 12 Jan 2004 12:20:52 -0000 1.11
+++ Makefile.am 12 Jan 2004 13:43:32 -0000 1.12
@@ -1,5 +1,5 @@
noinst_LTLIBRARIES = libcommon.la
-AM_CPPFLAGS = -Wall
+AM_CPPFLAGS = -Wall -DUSE_EXPAT_PARSER
libcommon_la_SOURCES = Param.cpp TypeMapping.cpp Packet.cpp MessageData.cpp \
BasicTypeSerializer.cpp ArrayBean.cpp AxisTime.cpp \
GDefine.cpp AxisUtils.cpp AxisTrace.cpp AxisException.cpp AxisConfig.cpp \
1.8 +1 -1 ws-axis/c/src/engine/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/ws-axis/c/src/engine/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Makefile.am 12 Jan 2004 12:20:53 -0000 1.7
+++ Makefile.am 12 Jan 2004 13:43:32 -0000 1.8
@@ -1,5 +1,5 @@
noinst_LTLIBRARIES = libengine.la
-AM_CPPFLAGS = -Wall
+AM_CPPFLAGS = -Wall -DUSE_EXPAT_PARSER
libengine_la_SOURCES = Axis.cpp \
AxisEngine.cpp \
ServerAxisEngine.cpp \
1.6 +1 -1 ws-axis/c/src/wsdd/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdd/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Makefile.am 12 Jan 2004 12:20:55 -0000 1.5
+++ Makefile.am 12 Jan 2004 13:43:32 -0000 1.6
@@ -1,5 +1,5 @@
noinst_LTLIBRARIES = libwsdd.la
-AM_CPPFLAGS = -Wall
+AM_CPPFLAGS = -Wall -DUSE_EXPAT_PARSER
libwsdd_la_SOURCES = WSDDDeployment.cpp \
WSDDHandler.cpp \
WSDDService.cpp \