Orion Interest Group,

I have written a Java class to test server to server communication for a
servlet running on Orion 1.5.2. Nothing seems to happen when I run the
class while the same URL sent from the address/location edit box on a
browser works perfectly. The host URL I am using is
"http://ducati:8080/petroweb/report"; where ducati is the name of my
notebook, petroweb is the application name, and report is the servlet I
am trying to access. Following is the code I am using to make the
"POST". What should I look for to make this work?

I have "System.out.println's" in my servlet code to notify the open
command prompt, in which Orion is running, of any requests received. I
also have, in my servlet, all "GET" requests resolving to the "doPost"
method.

My environment is Intel P850, MS Windows 2000 Professional. Sun jdks,
Orion 1.5.2 (stable binaries).

Thank you for your help.

import java.io.*;
import java.net.*;
import java.util.*;

public class PostTest {

  public static void main( String args[] ){
    String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                 "<pwCmdXML>" +
                 "<Command>SubmitJob</Command>" +
                 "<CommandPassword>aPwd</CommandPassword>" +
                 "<ProjectName>TheProject</ProjectName>" +
                 "<ProjectType>pType</ProjectType>" +
                 "<ObjectClass>stuff</ObjectClass>" +
                 "<ObjectList>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15," +
                 "16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31," +
                 "32,33,34,35,36</ObjectList>" +
                 "</pwCmdXML>";

    try{
      URL url = new URL( "http://ducati:8080/petroweb/report?"; );
      HttpURLConnection conn = (HttpURLConnection)url.openConnection();

      conn.setDoOutput( true );
      conn.setRequestMethod( "POST" );
      PrintWriter out = new PrintWriter(conn.getOutputStream() );

      out.println( "cmd=" + URLEncoder.encode( xml ) );
      conn.connect();
      out.flush();
      out.close();
    }
    catch( MalformedURLException err ){
      System.out.println( "MalformedURLException = " + err.getMessage()
);
    }
    catch( IOException err ){
      System.out.println( "IOException = " + err.getMessage() );
    }
  }
}



Reply via email to