axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ros...@apache.org
Subject cvs commit: xml-axis/c/vc Axis.dsw
Date Mon, 08 Sep 2003 06:45:17 GMT
roshan      2003/09/07 23:45:17

  Modified:    c/vc     Axis.dsw
  Added:       c/src/server/standaloneServer StandaloneServer.cpp
                        ServerHelper.h ServerHelper.cpp
               c/vc/server/standaloneServer StandaloneServer.dsp
  Log:
  adding files for standalone server
  
  Revision  Changes    Path
  1.1                  xml-axis/c/src/server/standaloneServer/StandaloneServer.cpp
  
  Index: StandaloneServer.cpp
  ===================================================================
  /*
   * Currently supports Windows only.
   */
  
  #include <winsock.h>    /* for socket(),... */
  #include <stdio.h>
  #include "../../common/Packet.h"
  #include "ServerHelper.h"
  
  #define MAXPENDING 5    /* Maximum outstanding connection requests */
  #define RCVBUFSIZE 1000   /* Size of receive buffer */
  
  char echoBuffer[RCVBUFSIZE];        /* Buffer for echo string */
  const char *pcHttpBody;
  int iClntSocket;
  
  int executeWork() {
  
  	Ax_soapstream* str = (Ax_soapstream*)malloc(sizeof(Ax_soapstream));
  	str->trtype = APTHTTP;
  	str->sessionid = "somesessionid";
  	str->so.http.ip_method = AXIS_HTTP_POST;
  	str->str.ip_stream = "is";
  	str->str.op_stream = "os";
  	str->so.http.ip_headers = (Ax_header*)malloc(sizeof(Ax_header));
  //	str->so.http.ip_headers->headername = SOAPACTIONHEADER;
  //	str->so.http.ip_headers->headervalue = "\"Calculator\"";	
  	str->so.http.ip_headercount = 0;
  	str->so.http.uri_path = "http://someurl/axis/Calculator";
  
  	printf("soap request :\n %s\n", echoBuffer);
  //	wprintf(L"soap request :\n %s\n", ip);
  
  	initialize_module();
  	
  	printf("Sending Soap Response :\n");
  	process_request(str);
  	printf("\n");
  	
  	uninitialize_module();
  	free(str->so.http.ip_headers);
  	free(str);
  
  	return 0;
  }
  
  int send_response_bytes(const char * res, const void* opstream) 
  {
  	//printf("calling send_response_bytes");
  	//printf("%s", res);
  
  	int iMsgSize = strlen(res);
  	
  	if (send(iClntSocket, res, iMsgSize, 0) == SOCKET_ERROR)
  		printf("%s\n","send() failed");	
  
  	return 0;
  }
  
  int get_request_bytes(char * req, int reqsize, int* retsize, const void* ipstream) 
  {
  	req[0]= '\0';
  	strcat(req, pcHttpBody);
  	*retsize= strlen(pcHttpBody);
  //	*retsize = wcslen(ip)*2;
  //	memcpy(req, ip, *retsize);
  	return 0;
  }
  
  int send_transport_information(Ax_soapstream* sSoapstream) 
  {
  	//printf("sending trasport info");
  	
  	char *res ="HTTP/1.1 200 OK\nContent-Type: text/xml; charset=utf-8\nDate: Wed, 03 Sep 2003
09:23:06 GMT\nConnection: close\n\n";
  
  	int iMsgSize = strlen(res);
  
  	if (send(iClntSocket, res, iMsgSize, 0) == SOCKET_ERROR)
  		printf("%s\n","send() failed");
  
  	return 0;
  }
  
  void printError(int x) {
  	if (x == WSANOTINITIALISED) {
  		printf("%s\n", "WSANOTINITIALISED");
  	} else if (x == WSAENETDOWN) {
  		printf("%s\n", "WSAENETDOWN");
  	} else if (x == WSAEFAULT) {
  		printf("%s\n", "WSAEFAULT");
  	} else if (x == WSAEINTR) {
  		printf("%s\n", "WSAEINTR");
  	} else if (x == WSAEINPROGRESS) {
  		printf("%s\n", "WSAEINPROGRESS");
  	} else if (x == WSAEINVAL) {
  		printf("%s\n", "WSAEINVAL");
  	} else if (x == WSAEMFILE) {
  		printf("%s\n", "WSAEMFILE");
  	} else if (x == WSAENOBUFS) {
  		printf("%s\n", "WSAENOBUFS");
  	} else if (x == WSAENOTSOCK) {
  		printf("%s\n", "WSAENOTSOCK");
  	} else if (x == WSAEOPNOTSUPP) {
  		printf("%s\n", "WSAEOPNOTSUPP");
  	} else if (x == WSAEWOULDBLOCK) {
  		printf("%s\n", "WSAEWOULDBLOCK");
  	} 
  }
  
  int createTCPServerSocket(unsigned short port)
  {
      int sock;                        /* socket to create */
      struct sockaddr_in echoServAddr; /* Local address */
  
      /* Create socket for incoming connections */
      if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
          printf("%s\n","socket() failed");
        
      /* Construct local address structure */
      memset(&echoServAddr, 0, sizeof(echoServAddr));   /* Zero out structure */
      echoServAddr.sin_family = AF_INET;                /* Internet address family */
      echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
      echoServAddr.sin_port = htons(port);              /* Local port */
  
      /* Bind to the local address */
      if (bind(sock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0)
          printf("%s\n","bind() failed");
  
      /* Mark the socket so it will listen for incoming connections */
      if (listen(sock, MAXPENDING) < 0)
          printf("%s\n","listen() failed");
  
      return sock;
  }
  
  int acceptTCPConnection(int servSock)
  {
      int clntSock;                    /* Socket descriptor for client */
      struct sockaddr_in echoClntAddr; /* Client address */
      //unsigned int clntLen;            /* Length of client address data structure */
  	int clntLen;            /* Length of client address data structure */
  
      /* Set the size of the in-out parameter */
      clntLen = sizeof(echoClntAddr);
      
      /* Wait for a client to connect */
      if ((clntSock = accept(servSock, (struct sockaddr *) &echoClntAddr, &clntLen))
< 0) {
          printf("%s\n","accept() failed");
  		int error = WSAGetLastError();		
  		printError(error);
  	}
      
      /* clntSock is connected to a client! */
      
      printf("Handling client %s\n", inet_ntoa(echoClntAddr.sin_addr));
  
      return clntSock;
  }
  
  void handleTCPClient(int clntSocket)
  {
      int recvMsgSize;                    /* Size of received message */
  	echoBuffer[0] = '\0';
  
      /* Receive message from client */
      if ((recvMsgSize = recv(clntSocket, echoBuffer, RCVBUFSIZE, 0)) < 0)
          printf("%s\n","recv() failed");
  
  	//DEBUG info
  	//printf("----------START request stream of client------------\n");
  	//printf("%s\n\n", echoBuffer);	
  	//printf("----------END request stream of client------------\n");
  
  	string sClientReqStream = string(echoBuffer);
  
  	string sHTTPHeaders = "";
  	string sHTTPBody = "";
  
  	getSeperatedHTTPParts(sClientReqStream, sHTTPHeaders, sHTTPBody);
  	
  	//DEBUG info
  	//printf("----------START extracted HTTP Headers------------\n");
  	//cout<<sHTTPHeaders<<endl;
  	//printf("----------END extracted HTTP Headers------------\n");
  
  	//DEBUG info
  	//printf("----------START extracted HTTP Body------------\n");
  	//cout<<sHTTPBody<<endl;
  	//printf("----------END extracted HTTP Body------------\n");
  
  	pcHttpBody = sHTTPBody.c_str();
  	iClntSocket = clntSocket;
  
  	executeWork();		
  
  	closesocket(clntSocket);    /* Close client socket */
  }
  
  int main(int argc, char *argv[ ])
  {
  
  	int *servSock;                   /* Socket descriptors for server */
  	WSADATA wsaData;                 /* Structure for WinSock setup communication */
  	fd_set sockSet;                  /* Set of socket descriptors for select() */
  	struct timeval selTimeout;       /* Timeout for select() */
  	long timeout= 1000;                    /* Timeout value given on command-line */
  	int running = 1;
  	int iServerPort;
  
  	int iPort;
  	int noPorts = 1;             /* Number of ports is argument count minus 2 */
  	servSock = (int *) malloc(noPorts * sizeof(int));
  
  	if (argc < 2) {
  		printf("Problem occured.\nUsage: %s <Server Port>", argv[0]);		
  		exit(1);
  	}	
  
  	if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) /* Load Winsock 2.0 DLL */
      {
          fprintf(stderr, "WSAStartup() failed");
          exit(1);
      }
  
  	/////////////
  	iServerPort = atoi(argv[1]);
  	if (iServerPort == 0) {
  		printf("Problem occured. Error in specified server port");
  		exit(1);
  	} else {
  		servSock[0] = createTCPServerSocket(iServerPort);
  	}
  	///////////////
  
  	while (running) {
  		FD_ZERO(&sockSet);
  		FD_SET(servSock[0], &sockSet);	
  
  
  		/* Timeout specification */
  		/* This must be reset every time select() is called */
  		selTimeout.tv_sec = timeout;       /* timeout (secs.) */
  		selTimeout.tv_usec = 0;            /* 0 microseconds */
  
  		if (select(0, &sockSet, NULL, NULL, &selTimeout) == 0)
  			printf("No echo requests for %ld secs...Server still alive\n", timeout);
  		else 
  		{        
  			if (FD_ISSET(servSock[0], &sockSet))
  			{
  				printf("Request on port %d (cmd-line position):  \n", 0);
  				handleTCPClient(acceptTCPConnection(servSock[0]));				
  			}
  		}
  
  		//DEBUG info
  		//printf("end of main while\n");
  	}
  
  	/* Close sockets */
      for (iPort = 0; iPort < noPorts; iPort++)
          closesocket(servSock[iPort]);
  
      /* Free list of sockets */
      free(servSock);
  
      WSACleanup();  /* Cleanup Winsock */
  
  	printf("End of main\n");
  
  	return 0;
  }
  
  
  1.1                  xml-axis/c/src/server/standaloneServer/ServerHelper.h
  
  Index: ServerHelper.h
  ===================================================================
  #include <string>
  
  using namespace std;
  
  int getSeperatedHTTPParts(string sClientReqStream, string& sHTTPHeaders, string&
sHTTPBody);
  
  
  1.1                  xml-axis/c/src/server/standaloneServer/ServerHelper.cpp
  
  Index: ServerHelper.cpp
  ===================================================================
  #include <iostream>
  #include <stdio.h>
  #include <string>
  
  using namespace std;
  
  int getSeperatedHTTPParts(string sClientReqStream, string& sHTTPHeaders, string&
sHTTPBody) {
  			
  	int iFindStartLocation=0;
  	string sTmpHttpHeader= "";
  	int iLocation=0;
  	bool bContinue= true;
  	int iGap;
  	bool bFirstTime= true;
  
  	/*
  	 *Extracts the HTTP Headers from the stream
  	 */
  	while(bContinue) {
  		
  		sTmpHttpHeader="";
  		iLocation = 0;
  		
  		iLocation = sClientReqStream.find('\n', iFindStartLocation);
  	
  		iGap = iLocation-iFindStartLocation;
  		if (iGap == 1) {
  			sTmpHttpHeader = sClientReqStream.substr(iFindStartLocation, (iLocation-iFindStartLocation));
	
  		} else {
  			sTmpHttpHeader = sClientReqStream.substr(iFindStartLocation, ((iLocation-iFindStartLocation)-1));
	
  		}				
  		
  		if(sTmpHttpHeader.size() == 1) {					
  			bContinue= false;
  		} else {										
  			if(bFirstTime) {
  				sHTTPHeaders += sTmpHttpHeader;
  				bFirstTime = false;
  			} else {
  				sHTTPHeaders += "|" + sTmpHttpHeader;
  			}													
  		}
  
  		iFindStartLocation = iLocation+1;
  	}
  
  	/*
  	 *Extracts the HTTP Body from the stream
  	 */
  	int iFullRequestLength= sClientReqStream.size();	
  	sHTTPBody = sClientReqStream.substr(iFindStartLocation, iFullRequestLength);		
  
  	// return a status code : 1- SUCCESS
  	return 1;
  }
  
  
  1.1                  xml-axis/c/vc/server/standaloneServer/StandaloneServer.dsp
  
  Index: StandaloneServer.dsp
  ===================================================================
  # Microsoft Developer Studio Project File - Name="StandaloneServer" - Package Owner=<4>
  # Microsoft Developer Studio Generated Build File, Format Version 6.00
  # ** DO NOT EDIT **
  
  # TARGTYPE "Win32 (x86) Console Application" 0x0103
  
  CFG=StandaloneServer - Win32 Debug
  !MESSAGE This is not a valid makefile. To build this project using NMAKE,
  !MESSAGE use the Export Makefile command and run
  !MESSAGE 
  !MESSAGE NMAKE /f "StandaloneServer.mak".
  !MESSAGE 
  !MESSAGE You can specify a configuration when running NMAKE
  !MESSAGE by defining the macro CFG on the command line. For example:
  !MESSAGE 
  !MESSAGE NMAKE /f "StandaloneServer.mak" CFG="StandaloneServer - Win32 Debug"
  !MESSAGE 
  !MESSAGE Possible choices for configuration are:
  !MESSAGE 
  !MESSAGE "StandaloneServer - Win32 Release" (based on "Win32 (x86) Console Application")
  !MESSAGE "StandaloneServer - Win32 Debug" (based on "Win32 (x86) Console Application")
  !MESSAGE 
  
  # Begin Project
  # PROP AllowPerConfigDependencies 0
  # PROP Scc_ProjName ""
  # PROP Scc_LocalPath ""
  CPP=cl.exe
  RSC=rc.exe
  
  !IF  "$(CFG)" == "StandaloneServer - Win32 Release"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 0
  # PROP BASE Output_Dir "Release"
  # PROP BASE Intermediate_Dir "Release"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 0
  # PROP Output_Dir "Release"
  # PROP Intermediate_Dir "Release"
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD
/c
  # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
  # ADD BASE RSC /l 0x409 /d "NDEBUG"
  # ADD RSC /l 0x409 /d "NDEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
  # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib
ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib /nologo /subsystem:console /machine:I386
  
  !ELSEIF  "$(CFG)" == "StandaloneServer - Win32 Debug"
  
  # PROP BASE Use_MFC 0
  # PROP BASE Use_Debug_Libraries 1
  # PROP BASE Output_Dir "Debug"
  # PROP BASE Intermediate_Dir "Debug"
  # PROP BASE Target_Dir ""
  # PROP Use_MFC 0
  # PROP Use_Debug_Libraries 1
  # PROP Output_Dir "../../../release/win32"
  # PROP Intermediate_Dir "../../../bin/win32/standaloneServer"
  # PROP Ignore_Export_Lib 0
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS"
/YX /FD /GZ /c
  # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../include ../../include" /D "WIN32" /D
"_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c
  # ADD BASE RSC /l 0x409 /d "_DEBUG"
  # ADD RSC /l 0x409 /d "_DEBUG"
  BSC32=bscmake.exe
  # ADD BASE BSC32 /nologo
  # ADD BSC32 /nologo
  LINK32=link.exe
  # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
  # ADD LINK32 Common_D.lib Soap_D.lib wsdd_D.lib xerces-c_2D.lib wsock32.lib /nologo /subsystem:console
/debug /machine:I386 /out:"../../../release/win32/StandaloneServer_D.exe" /pdbtype:sept /libpath:"../../../lib/win32/axis"
/libpath:"../../../lib/win32/xercesc"
  
  !ENDIF 
  
  # Begin Target
  
  # Name "StandaloneServer - Win32 Release"
  # Name "StandaloneServer - Win32 Debug"
  # Begin Group "Source Files"
  
  # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\AppScopeHandlerPool.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\Axis.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\AxisEngine.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\DeserializerPool.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\HandlerChain.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\HandlerLoader.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\HandlerPool.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\RequestScopeHandlerPool.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\SerializerPool.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\server\standaloneServer\ServerHelper.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\SessionScopeHandlerPool.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\SharedObject.cpp
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\server\standaloneServer\StandaloneServer.cpp
  # End Source File
  # End Group
  # Begin Group "Header Files"
  
  # PROP Default_Filter "h;hpp;hxx;hm;inl"
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\AppScopeHandlerPool.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\AxisEngine.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\DeserializerPool.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\HandlerChain.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\HandlerLoader.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\HandlerPool.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\RequestScopeHandlerPool.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\SerializerPool.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\server\standaloneServer\ServerHelper.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\SessionScopeHandlerPool.h
  # End Source File
  # Begin Source File
  
  SOURCE=..\..\..\src\engine\SharedObject.h
  # End Source File
  # End Group
  # Begin Group "Resource Files"
  
  # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
  # End Group
  # End Target
  # End Project
  
  
  
  1.4       +12 -0     xml-axis/c/vc/Axis.dsw
  
  Index: Axis.dsw
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/vc/Axis.dsw,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Axis.dsw	28 Aug 2003 04:21:43 -0000	1.3
  +++ Axis.dsw	8 Sep 2003 06:45:17 -0000	1.4
  @@ -99,6 +99,18 @@
   
   ###############################################################################
   
  +Project: "StandaloneServer"=".\SERVER\StandaloneServer\StandaloneServer.dsp" - Package
Owner=<4>
  +
  +Package=<5>
  +{{{
  +}}}
  +
  +Package=<4>
  +{{{
  +}}}
  +
  +###############################################################################
  +
   Project: "WSDD"=".\WSDD\WSDD.dsp" - Package Owner=<4>
   
   Package=<5>
  
  
  

Mime
View raw message