1 #include "CreateConfigFile.h"
2 #include "CreateConfigFileResponse.h"
4 #include "GetFileResponse.h"
6 #include "PutFileResponse.h"
7 #include "SimanSalomeServiceStub.h"
8 #include <Environment.h>
11 #include <ServiceClient.h>
14 #include <axis2_util.h>
15 #include <axiom_soap.h>
16 #include <axis2_client.h>
17 #include <axutil_uuid_gen.h>
21 using namespace org_splat_ws_server_service_salome;
22 using namespace wso2wsf;
24 int main(int argc, char *argv[])
26 std::string endpointUri = "http://172.22.2.10:8080/Siman-WS/services/SimanSalomeService";
28 char * ttest = getenv("SIMAN_WS_HOS");
34 string aSimanWSHost(getenv("SIMAN_WS_HOST"));
35 string endpointUriTT = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService";
37 cout<<"enpoint uri" << endpointUriTT << "\n";
39 Environment::initialize("SimanSalomeService.log",AXIS2_LOG_LEVEL_DEBUG);
41 //std::string clientHome = AXIS2_GETENV("SALOME_HOME");
42 std::string clientHome = AXIS2_GETENV("WSFCPP_HOME");
43 //std::string clientHome = "/dn24/SIMAN/siman_mandriva_2010";
44 SimanSalomeServiceStub* aStub = new SimanSalomeServiceStub(clientHome, endpointUri);
45 //SimanSalomeServiceStub* aStub = new SimanSalomeServiceStub(clientHome);
46 ServiceClient *client = aStub->getServiceClient();
49 client->engageModule(AXIS2_MODULE_ADDRESSING);
50 Options *options = client->getOptions();
51 axis2_options_t *axis2options = options->getAxis2Options();
52 axis2_options_set_action(axis2options, Environment::getEnv(), "urn:createConfigFile");
55 //axis2_options_set_enable_mtom(axis2options, Environment::getEnv(), AXIS2_TRUE);
56 options->setTimeout(1000000);
57 options->setSoapVersion(AXIOM_SOAP12);
59 CreateConfigFile* aRequest = new CreateConfigFile();
61 long long studyId = 1000;
62 long long scenarioId = 1001;
64 string newUserId = "8";
66 aRequest->setArgs0(studyId);
67 aRequest->setArgs1(scenarioId);
68 aRequest->setArgs2(atoll(newUserId.c_str()));
70 CreateConfigFileResponse* aResponse = new CreateConfigFileResponse();
72 aResponse = aStub->createConfigFile(aRequest);
74 cout<< "Response:: "<<aResponse->get_return()<<endl;
76 //Parse the response and get the filename
77 std::string aResponseFilePath = aResponse->get_return();
78 std::string aResponseFileName = aResponseFilePath.substr(aResponseFilePath.find_last_of("/\\")+1);
79 cout << aResponseFileName << "\n";
82 axis2_options_set_action(axis2options, Environment::getEnv(), "urn:getFile");
84 GetFile* aGetFileRequest = new GetFile();
85 aGetFileRequest->setArgs0(aResponse->get_return());
87 GetFileResponse* aGetFileResponse = new GetFileResponse();
88 aGetFileResponse = aStub->getFile(aGetFileRequest);
89 std::ofstream outputStream;
90 std::string aClientFilePath = "/dn24/SIMAN/siman_temp/download/" + aResponseFileName;
92 outputStream.open(aClientFilePath.c_str(), ofstream::binary);
94 int aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv());
96 cout<<aBufferSize<<"\n";
97 int* aBufSize = new int[aBufferSize];
98 unsigned char* aCopyBuffer = axutil_base64_binary_get_plain_binary(aGetFileResponse->get_return(), Environment::getEnv(), aBufSize);
99 //char* aCopyBuf = aCopyBuf;
101 //outputStream << aGetFileResponse->get_return();
102 outputStream.write(reinterpret_cast<const char*>(aCopyBuffer),aBufferSize);
104 outputStream.flush();
105 outputStream.close();
108 /*string aSourceLoc = "W:\\testvideo\\Darvin.avi";
109 aGetFileRequest->setArgs0(aSourceLoc);
110 aGetFileResponse = aStub->getFile(aGetFileRequest);
112 outputStream.open("/dn24/SIMAN/siman_temp/download/Darvin.avi", ofstream::binary);
113 aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv());
114 cout<<aBufferSize<<"\n";
116 aBufSize = new int[aBufferSize];
117 aCopyBuffer = axutil_base64_binary_get_plain_binary(aGetFileResponse->get_return(), Environment::getEnv(), aBufSize);
119 outputStream.write(reinterpret_cast<const char*>(aCopyBuffer),aBufferSize);
121 outputStream.flush();
122 outputStream.close();
125 cout << "See file on path" << aClientFilePath << "\n";
128 axis2_options_set_action(axis2options, Environment::getEnv(), "urn:putFile");
130 PutFile* aPutFileRequest = new PutFile();
131 //char* aSourceFile = "/dn24/SIMAN/siman_temp/download/Mesh_1.med";
133 //get size of the input file
134 ifstream infile ("/dn24/SIMAN/siman_temp/download/Mesh_1.med",ifstream::binary);
135 infile.seekg(0,ifstream::end);
136 int aSize = infile.tellg();
137 cout << "Size of the input file is: " << aSize << "\n";
141 inBuffer = new char [aSize];
142 infile.read(inBuffer,aSize);
144 axutil_base64_binary_t* aRequestDH = axutil_base64_binary_create_with_plain_binary(Environment::getEnv(), reinterpret_cast<unsigned char*>(inBuffer), aSize);
150 aPutFileRequest->setArgs0(aRequestDH);
151 aPutFileRequest->setArgs1("Mesh_1.med");
152 aPutFileRequest->setArgs2(userId);
154 cout << "test" <<"\n";
156 PutFileResponse* aPutFileResponse = new PutFileResponse();
157 aPutFileResponse = aStub->putFile(aPutFileRequest);
159 cout<< "Response:: "<<aPutFileResponse->get_return()<<endl;
163 delete aGetFileResponse;
164 delete aGetFileRequest;
165 delete aPutFileResponse;
166 delete aPutFileRequest;