00001 #include <iostream>
00002 #include "TestClient.h"
00003 #include "networkApp.h"
00004 #ifdef _MSC_VER
00005 #include <io.h>
00006 #endif
00007 #include <iostream>
00008 #include <fstream>
00009
00010 #define VersionString "Simple SOAP Test Client 2.1 build 0"
00011
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 char *ServerObject = NULL;
00048
00049 int networkAppMain( int argc, char* argv[] )
00050 {
00051 TestSOAPClient testSOAP;
00052
00053 std::cout << VersionString << std::endl;
00054 if ( argc < 2 )
00055 {
00056 std::cout << "usage: media.xml ServerObjectName TestListfile <IP Address> <port>" << std::endl
00057 << "Default IP 127.0.0.1 Default Port 8080" << std::endl ;
00058 return 1;
00059 }
00060
00061 if ( access( argv[2], 4 ) != 0 )
00062 {
00063 std::cout << "Could not access file " << argv[2] ;
00064 return 1;
00065 }
00066
00067 ServerObject = argv[1];
00068 std::string listFile = argv[2];
00069 std::ifstream inpList;
00070 inpList.open( listFile.c_str(), std::ios_base::in );
00071 if ( !inpList.is_open() )
00072 {
00073 std::cout << "cannot open list file: " << listFile << std::endl;
00074 return 1;
00075 }
00076
00077
00078 testSOAP.setEndPoint( argc < 4 ? std::string( "127.0.0.1" ) : std::string( argv[3] ),
00079 argc < 5 ? 8080 : atoi( argv[4] ) );
00080
00081 std::string listPath = listFile;
00082 while ( listPath.end() != listPath.begin() )
00083 {
00084 if ( ( *--listPath.end() == ':' ) ||
00085 ( *--listPath.end() == '/' ) ||
00086 ( *--listPath.end() == '\\') )
00087 break;
00088 else
00089 listPath.erase( --listPath.end() );
00090
00091 if ( ( *(listPath.end()-1) == ':' ) ||
00092 ( *(listPath.end()-1) == '/' ) ||
00093 ( *(listPath.end()-1) == '\\') )
00094 break;
00095 else
00096 listPath.erase(listPath.end()-1);
00097 }
00098 try
00099 {
00100 std::string rpcFilename;
00101 while ( !inpList.eof() )
00102 {
00103 getline( inpList, rpcFilename );
00104
00105 if ( rpcFilename.empty() || ( rpcFilename[0] == '#' ) )
00106 continue;
00107
00108
00109 std::ifstream inpRPC;
00110
00111 if ( rpcFilename[ rpcFilename.length()-1 ] == '\r' )
00112 rpcFilename[ rpcFilename.length()-1 ] = 0;
00113 inpRPC.open( rpcFilename.c_str(), std::ios_base::in );
00114 if ( !inpRPC.is_open() )
00115 {
00116 std::cout << "cannot open RPC file: " << rpcFilename << std::endl;
00117 return 1;
00118 }
00119
00120
00121 std::ostringstream rpcCall;
00122 rpcCall << inpRPC.rdbuf();
00123
00124
00125 std::cout << "\r\n\n===================== " << rpcFilename << " ============================\r\n\n";
00126 std::cout << "\r\n\n--------------------- " << rpcFilename << " Return ---------------------\r\n\n"
00127 << testSOAP.Generic( rpcCall.str() );
00128
00129 inpRPC.close();
00130 }
00131 }
00132 catch ( std::exception& e )
00133 {
00134 std::cerr << e.what() << std::endl;
00135 return -1;
00136 }
00137
00138 std::cout << std::endl << "Normal termination of test run" << std::endl;
00139 return 0;
00140 }
00141
00142
00143 int main( int argc, char* argv[] )
00144 {
00145 return NetworkStart( argc, argv, networkAppMain );
00146 }