Using the Simple Post Utility Using a Java API

You can use the Simple Post utility using a Java API.

This section provides code examples that demonstrate how to:

  • Construct a Java file containing Simple Post parameters.

  • Compile the Java file.

  • Run the test program.

The following example shows a submission via a Java API:

// Import the SimplePost API
import com.peoplesoft.pt.simplepost.SimplePost;

/** Test class to use SimplePost functionality */
public class TestSimplePost {

      /** Constructor */
      public TestSimplePost() {}

      public static void main (String argv []) {

        // Create the SimplePost object
        SimplePost mainSPObj = new SimplePost();

        // Turn on printouts
        mainSPObj.setVerbose(true);

        // Use this function to see the output stream, 
        // defaulted to System.out
        // mainSPObj.setOutputPrintStream(<PrintStream>);

        // Turn on Encoding for 8.53
        mainSPObj.setEncoding(true);

      // SET THE REQUIRED DATA

        // Requesting NodemainSPObj.setRequestingNode("QE_UNDERDOG");

        // Operation NamemainSPObj.setMessageName("QE_SYNC_MSG.v1");

        // Server URL, must be the HttpListeningConnector or a 
        //connector that can accept an IBRequest XML messagemainSPObj.setServerURL("http://localhost/PSIGW/
        HttpListeningConnector");

        // Input file name, root node name must be the name of the messagemainSPObj.setInputFileName("c:\\temp\\
       QE_SYNC_MSG.xml");

      /*  // Optional data
        mainSPObj.setMessageType(MESSAGE_TYPE_SYNC);
        mainSPObj.setDestinationNode("QE_LOCAL");
        mainSPObj.setTimeOut(2.5);
        mainSPObj.setPassword("");
        mainSPObj.setOriginatingUser("");
        mainSPObj.setOriginatingNode("");
        mainSPObj.setOriginatingProcess("");
        mainSPObj.setSubChannel("");
        mainSPObj.setFinalDestinationNode("");
      */

        // Post the data
        boolean returnValue = mainSPObj.post();

        // Check the return value
        if (!returnValue) {

        // False, printout the error message
        System.out.println(mainSPObj.getMessage());

        } else {

        // Success!

        // Printout the return code and server message
        System.out.println("\n" + mainSPObj.getResponseCode() + " - " + 
        mainSPObj.getResponseMessage());

        // Printout the headers
        System.out.print("\n" + mainSPObj.getResponseHeaders() + "\n");

        // Printout the data
        System.out.print("\n" + mainSPObj.getResponseData());
     }
   }
}

The following example shows a command line for compiling the Java file. In this example, the Java file name is TestSimplePost.java:

javac -classpath "C:\PT8.53\webserv\ps\applications\peoplesoft\PSIGW.war\
WEB-INF\classes;." TestSimplePost.java

The following example shows how to invoke the test program.

java -classpath "C:\PT8.53\webserv\ps\applications\peoplesoft\PSIGW.war\
WEB-INF\classes;." TestSimplePost