2016-08-12 12 views
1

現在、資格情報とXMLをTextPaneまたはファイルから選択するためにシステムに取り組んでいますが、FileChooserでそのパスを取得します。私の質問は、誰かがHttpsUrlConnectionの設定方法を知っているかどうかです。 getEncodingFromPartner(/ 0/1) ActDelivery_HTTP.Inbound:receiveXML(/ 0/0/0) UTF-Iは、そのが.setRequestPropertyまたは.addRequestPropertyによって行われますが、サーバーは、このエラーにJava HttpsURLConnectionの設定

ActDelivery_HTTP.Utilsを投げていることを理解し8

私は多くの研究をしましたが、私はJavaではそれほど良くありません。だから誰かが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

Authenticatorは、Webサイトに組み込まれているBasic Authentication Systemに資格情報を提供するために使用されます。それはあなたが欲しいものですか? または、レスポンスでプロパティとしてクレデンシャルを送信したいだけですか? –

答えて

1

どのような構成を参照していますか?あなたはどんな問題に直面していますか?そして、あなたはどんなエラーを出していますか?

HTTP POST本体で一部のコンテンツを送信する場合は、URL接続の出力ストリームにその内容を書き込む必要があります。

output.writeBytes( "mytextcontent");

内容の種類に応じて、適切なAPIまたは出力ストリームを使用する必要があります。

+0

Rajeshさん、ありがとうございます私はより具体的な私の質問をしたが、私は自分のコードで問題を発見し、誰もがそれを見ることができる私の質問に適切に編集しました。 – 404TecZ