2016-08-12 1 views
1

현재 TextPane 또는 파일에서 선택한 자격 증명과 XML을 전송하기 위해 시스템에서 작업 중이므로 FileChooser을 사용하여 경로를 얻습니다. 내 질문은 누군가가 설명을 알고있는 경우 HttpsUrlConnection 구성하는 방법입니다. getEncodingFromPartner (/ 0/1) ActDelivery_HTTP.Inbound : receiveXML (/ 0/0/0) UTF-I는이 .setRequestProperty 또는 .addRequestProperty 수행하지만 서버가이 오류를Java HttpsURLConnection 구성

ActDelivery_HTTP.Utils을 던지고 이해 8

나는 많은 연구를 해왔지만, 자바에서는 그렇게 좋지 않다. 그래서 누군가가 HttpsUrlConnection의 구성을 설명 할 수 있는지 묻습니다.

    try { 

         Authenticator.setDefault (new Authenticator() { 
          protected PasswordAuthentication getPasswordAuthentication() { 
           return new PasswordAuthentication (textUser.getText(), textPass.getText().toCharArray()); 
          } 
         }); 

         URL myurl = new URL(httpsURL); 
         HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection(); 
         con.setRequestMethod("POST"); 

         con.setRequestProperty("Content-length", URLEncoder.encode(textXML.getText(), "UTF-8")); 
         con.setRequestProperty("Content-Type","text/xml; charset=UTF-8"); 
         con.setRequestProperty("Https-Agent", ""); 
         con.setRequestProperty("Content", URLEncoder.encode(textXML.getText(), "UTF-8")); 
         con.setRequestProperty("Dest-Port", "443");                     // I'm not sure how to add the xml as request 
         con.setDoOutput(true);                // out of a text box or just the file at all 
         con.setDoInput(true); 

         DataOutputStream output = new DataOutputStream(con.getOutputStream()); 


         output.writeBytes(textXML.getText()); 

         output.close(); 

         DataInputStream input = new DataInputStream(con.getInputStream()); 



         for(int c = input.read(); c != -1; c = input.read()) 
         System.out.print((char)c); 
         input.close(); 

         System.out.println("Resp Code:"+con .getResponseCode()); 
         System.out.println("Resp Message:"+ con .getResponseMessage()); 
+0

인증자는 웹 사이트에 통합 된 기본 인증 시스템에 자격 증명을 제공하는 데 사용됩니다. 너가 원하는게 그거야 ? 또는 응답의 자격 증명으로 자격 증명을 보내시겠습니까? –

답변

1

어떤 구성을 말하는가? 그리고 당신이 직면 한 이슈는 무엇입니까? 그리고 어떤 오류가 있습니까?

HTTP POST 본문에서 일부 내용을 보내려면 URL 연결의 출력 스트림에 내용을 기록해야합니다.

output.writeBytes ("mytextcontent");

내용 유형에 따라 적절한 API 또는 출력 스트림을 사용해야합니다.

+0

감사합니다 Rajesh 내가 더 구체적인 내 질문을 만들지 만 내 코드에서 문제를 발견하고 모든 사람들이 볼 수있는 내 질문에 올바르게 편집했습니다. – 404TecZ