import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import org.omg.CORBA.portable.InputStream;
public class httpURLCon {
 public static void main(String[] args) throws UnsupportedEncodingException{
  
   String data = "DATADATA?SVCID=SKKU160R&KEY=4s";
   
  String strURL = "http://XXX.XXX.XXX.XXX:51000/sap/xi/adapter_plain?";
  strURL = strURL + URLEncoder.encode("namespace", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("http://test.com/pilot/01/scenario1", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("interface", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("Act_Out", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("service", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("ZPILOT_Legacy_BS", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("receiverService", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("ZPILOT_Legacy_BS", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("QOS", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("BE", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("sap-user", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("계정", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("sap-password", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("비번", "UTF-8") + "&";
      
  System.out.println(strURL); 
  
  try{
   HttpURLConnection httpURLCon = null;
   OutputStream outs = null;
   
   URL url = new URL(strURL);
   
   httpURLCon = (HttpURLConnection) url.openConnection();
   httpURLCon.setRequestMethod("POST");
   httpURLCon.setDoInput(true);
   httpURLCon.setDoOutput(true);
   httpURLCon.setUseCaches(false);
   httpURLCon.setDefaultUseCaches(false);
   httpURLCon.setRequestProperty("CONTENT-TYPE", "Application/x-www-form-urlencoded");
   httpURLCon.connect();
   
   outs = httpURLCon.getOutputStream();
   byte[] sendByte = new String(data).getBytes("KSC5601");
   
   outs.write(sendByte);
   outs.close();
   //httpURLCon.connect();
   
   String line;
   BufferedReader reader = new BufferedReader(new InputStreamReader(httpURLCon.getInputStream()));
   
   while((line = reader.readLine()) != null) {
    System.out.println(line); 
   }
/*         
   if (httpURLCon.getResponseCode() == HttpURLConnection.HTTP_OK) {
    System.out.println("1ResponseCode : " + httpURLCon.getResponseCode()); 
   }else {
    System.out.println("2ResponseCode : " + httpURLCon.getResponseCode()); 
   }
*/   
  }catch(Exception e) {
   System.out.println(e.toString()); 
  }
 }
}
Posted by INSPIEN
,