next up previous contents
Next: Examples Up: Applications Previous: AMPL Client: Hooking AMPL   Contents


File Upload: Using a File Upload Package

When the OSAgent class methods solve and send are used, the problem instance in OSiL format is packaged into a SOAP envelope and communication with the server is done using Web Services (for example Tomcat Axis). However, packing an XML file into a SOAP envelope may add considerably to the size of the file (each $ <$ is replaced with &lt; and each $ >$ is replaced with &gt;). Also, communicating with a Web Services servlet can also slow down the communication process. This could be a problem for large instances. An alternative approach is to use the fileUpload executable on the client end and the Java servlet OSFileUpload on the server end. The fileUpload client executable is contained in the fileUpload directory inside the examples directory.

This servlet is based upon the Apache Commons FileUpload. See http://jakarta.apache.org/commons/fileupload/. The OSFileUpload Java class , OSFileUpload.class is in the directory

webapps\os\WEB-INF\classes\org\optimizationservices\oscommon\util
relative to the Web server root. The source code OSFileUpload.class is in the directory
 COIN-OS/OS/applications/fileUpload

The fileUpload client executable (see OS/applications/fileUpload) takes one argument on the command line which is the location of the file on the local directory to upload to the server. For example,

fileUpload ../../data/osilFiles/parincQuadratic.osil
The fileUpload executable first creates an OSAgent object.
OSSolverAgent* osagent = NULL;
osagent = new OSSolverAgent("http://gsbkip.chicagogsb.edu/fileupload/servlet/OSFileUpload");
The OSAgent has a method fileUpload with the signature
std::string fileUpload(std::string osilFileName, std::string osil);
where osilFileName is the name of the OSiL problem instance to be written on the server and osil is the string with the actual instance. Then
osagent->fileUpload(osilFileName, osil);
will place a call to the server, upload the problem instance in the osil string, and cause the server to write a file on its hard drive named osilFileName. In our implementation, the uploaded file (parincQuadratic.osil) is saved to the /home/kmartin/temp/parincQuadratic.osil on the server hard drive. This location is used in the osol file as shown below.

Once the file is on the server, invoke the local OSSolverService by

./OSSolverService -config ../data/configFiles/testremote.config
where the config file is as follows. Notice there is no -osil option as the osil file has already been uploaded and its instance location ("local" to the server) is specified in the osol file.
-osol ../data/osolFiles/remoteSolve2.osol
-serviceLocation http://gsbkip.chicagogsb.edu/os/OSSolverService.jws
-serviceMethod solve
and the osol file is
\begin{verbatimtab}[5]
<osol>
<general>
<instanceLocation locationType=''local...
...ther name=''os_solver''>ipopt</other>
</optimization>
</osol>
\end{verbatimtab}

As an alternative to using the command line executable fileUpload, there is also an html form fileupload.html that can be used to upload files. For example, the URL

http://gsbkip.chicagogsb.edu/os/fileupload.html
will bring up the necessary form that allows the user to browse a directory and select the file to upload. This URL is based on the assumption that the OSJava classes were deployed as described in Section 11. The file fileupload.html is in the directory WebApps/os. In our html form implementation, after you upload the OSiL file, it shows you the path of the uploaded file that is saved on the server, so that you can put it in the corresponding osol file.


next up previous contents
Next: Examples Up: Applications Previous: AMPL Client: Hooking AMPL   Contents
Kipp Martin 2008-01-16