00001 #include <Ice/Ice.h> 00002 #include "HelloWorld.ice.H" 00003 00004 using namespace std; 00005 using namespace Demo; 00006 00007 int main(int argc, char* argv[]) { 00008 int status = 0; 00009 Ice::CommunicatorPtr ic; 00010 try { 00011 ic = Ice::initialize(argc, argv); 00012 Ice::ObjectPrx base = ic->stringToProxy( 00013 "SimpleHelloWorld:default -p 10000"); 00014 HelloWorldPrx helloWorld = HelloWorldPrx::checkedCast(base); 00015 if(!helloWorld) 00016 throw "Invalid proxy"; 00017 if(argc > 1) { 00018 cout << "Sending String..." << endl; 00019 helloWorld->printString(argv[1]); 00020 cout << "String Send" << endl; 00021 } 00022 else { 00023 helloWorld->printString("Default message"); 00024 } 00025 } 00026 catch (const Ice::Exception& ex) { 00027 cerr << "ERROR CAUGHT!" << ex << endl; 00028 status = 1; 00029 } 00030 catch(const char* msg) { 00031 cerr << "ERROR CAUGHT!" << msg << endl; 00032 status = 1; 00033 } 00034 if (ic) 00035 ic->destroy(); 00036 return status; 00037 }