18 #include "CoinTime.hpp"
19 #include "OSParameters.h"
30 # error "don't have header file for time"
38 using std::ostringstream;
45 string::size_type nstart = 0;
46 string::size_type posSlash;
49 if (solverURI.find(
"http://") != string::npos) solverURI = solverURI.substr(7);
51 posSlash = solverURI.find(
"/", nstart);
52 if(posSlash != std::string::npos) nstart = posSlash;
53 postURI = solverURI.substr(nstart, solverURI.size() - 1);
55 string::size_type colonlocation = solverURI.find(
":");
56 if(colonlocation == string::npos)
63 solverPortNumber = (
unsigned short) atoi( &solverURI.substr(colonlocation + 1, nstart - colonlocation - 1)[0] ) ;
81 std::ostringstream outStr;
85 outStr <<
"Sending to the remote system:" << std::endl << std::endl;
86 outStr <<
"OSiL string:" << std::endl << std::endl;
87 outStr << osil << std::endl << std::endl;
88 outStr <<
"OSoL string:" << std::endl << std::endl;
89 outStr << osol << std::endl << std::endl;
97 string smethod =
"solve";
115 string msInputNames[2] = {
"osil",
"osol"};
116 string sSoapAction =
"OSSolverService#solve";
119 double startTime = 0;
120 startTime = CoinCpuTime();
122 smethod, msInputs, msInputNames, sSoapAction);
124 cpuTime = CoinCpuTime() - startTime;
125 startTime = CoinWallclockTime();
135 cpuTime = CoinWallclockTime() - startTime;
158 string theHTTPPOST=
"";
159 string uploadResult=
"";
160 string boundaryName =
"AaB03x";
162 osilFileName, theOSiLFile, boundaryName);
178 bool useCDATA =
true;
183 std::ostringstream outStr;
187 outStr <<
"Sending to the remote system:" << std::endl << std::endl;
188 outStr <<
"OSiL string:" << std::endl << std::endl;
189 outStr << osil << std::endl << std::endl;
190 outStr <<
"OSoL string:" << std::endl << std::endl;
191 outStr << osol << std::endl << std::endl;
198 string smethod =
"send";
216 string msInputNames[2] = {
"osil",
"osol"};
217 string sSoapAction =
"OSSolverService#send";
220 smethod, msInputs, msInputNames, sSoapAction);
248 if( sendResult.find(
"true") != string::npos )
return true;
255 string getJobIDResult;
257 bool useCDATA =
true;
262 std::ostringstream outStr;
266 outStr <<
"Sending to the remote system:" << std::endl << std::endl;
267 outStr <<
"OSoL string:" << std::endl << std::endl;
268 outStr << osol << std::endl << std::endl;
275 string smethod =
"getJobID";
287 string msInputNames[1] = {
"osol"};
288 string sSoapAction =
"OSSolverService#getJobID";
291 smethod, msInputs, msInputNames, sSoapAction);
323 string retrieveResult;
325 bool useCDATA =
true;
330 std::ostringstream outStr;
334 outStr <<
"Sending to the remote system:" << std::endl << std::endl;
335 outStr <<
"OSoL string:" << std::endl << std::endl;
336 outStr << osol << std::endl << std::endl;
343 string smethod =
"retrieve";
354 string msInputNames[1] = {
"osol"};
355 string sSoapAction =
"OSSolverService#retrieve";
358 smethod, msInputs, msInputNames, sSoapAction);
397 bool useCDATA =
true;
402 std::ostringstream outStr;
406 outStr <<
"Sending to the remote system:" << std::endl << std::endl;
407 outStr <<
"OSoL string:" << std::endl << std::endl;
408 outStr << osol << std::endl << std::endl;
415 string smethod =
"kill";
426 string msInputNames[1] = {
"osol"};
427 string sSoapAction =
"OSSolverService#kill";
430 smethod, msInputs, msInputNames, sSoapAction);
463 bool useCDATA =
true;
467 std::ostringstream outStr;
471 outStr <<
"Sending to the remote system:" << std::endl << std::endl;
472 outStr <<
"OSpL string:" << std::endl << std::endl;
473 outStr << ospl << std::endl << std::endl;
474 outStr <<
"OSoL string:" << std::endl << std::endl;
475 outStr << osol << std::endl << std::endl;
482 string smethod =
"knock";
499 string msInputNames[2] = {
"ospl",
"osol"};
500 string sSoapAction =
"OSSolverService#knock";
503 smethod, msInputs, msInputNames, sSoapAction);
static std::string createSOAPMessage(int numInputs, std::string solverAddress, std::string postURI, std::string smethod, std::string *msInputs, std::string *msInputNames, std::string sSoapAction)
create the SOAP message that is send to the solver Web Service
std::string retrieve(std::string osol)
implement the retrieve() method which is a virtual function in OShL
const OSSmartPtr< OSOutput > osoutput
bool send(std::string osil, std::string osol)
implement the send() method which is a virtual function in OShL
static std::string getOSxL(std::string soapstring, std::string serviceMethod)
extract the appropriate OSxL protocol from the SOAP envelop
An interface that specified virtual methods to be implemented by agents.
bool OSPrint(ENUM_OUTPUT_AREA area, ENUM_OUTPUT_LEVEL level, std::string outStr)
This is the main method to output a string All output generated by the program should ultimately use ...
std::string solve(std::string osil, std::string osol)
implement the solve() method which is a virtual function in OShL, this is synchronous ...
Template class for Smart Pointers.
std::string solverAddress
solverAddress is the URI for the solver
OSSolverAgent(std::string solverURI)
Default constructor.
unsigned short solverPortNumber
solverPortNumber is the port number for the solver
static std::string createFormDataUpload(std::string solverAddress, std::string postURI, std::string fileName, std::string theFile, std::string boundaryName)
create the SOAP message that is sent to the solver Web Service
std::string fileUpload(std::string osilFileName, std::string osil)
implement the fileUpload() method which is a virtual function in OShL
static std::string deSOAPify(std::string theXmlString, bool useCDATA)
take the XML from a SOAP envelop and replace < with < replace > with > replace &quot with "; ...
std::string knock(std::string ospl, std::string osol)
implement the knock() method which is a virtual function in OShL
static std::string SOAPify(std::string theXmlString, bool useCDATA)
prepare XML to be put into a SOAP envelop, replace < with < replace > with > replace " and ' with ...
std::string postURI
postURI is the path to the solver that follows the first '/' in the solverAddress ...
~OSSolverAgent()
Class destructor.
std::string kill(std::string osol)
implement the kill() method which is a virtual function in OShL
std::string getJobID(std::string osol)
implement the getJobID() method which is a virtual function in OShL
static std::string sendSOAPMessage(std::string theSOAP, std::string serviceIP, unsigned int servicePortNumber)
open a socket and send a SOAP message to the solver Web Service