0

まず、Stackoverflow の助けを借りて、URL から XML 応答を読み取ることができました。これと他の多くの助けに感謝します。応答 (以下のコード) を読んで印刷しましたが、結果が正しくありません。

ブラウザに表示されます(正しい):

<ENELIT>
<GESI>
<RI>
<NR id="008201dfa306f4a2" tu="N" nr="0412395504" ut="" cp="" dp="" tm="" ca="" da="" rt="" cc="4"/>
</RI>
</GESI>
</ENELIT>

そしてJavaでは、これを出力します(間違っています):

<html>
  <head>
    <link rel=stylesheet href="/psiche/styles/IEStyle.css" type="text/css">
  </head>
  <body>

    <SCRIPT FOR=window EVENT=onload LANGUAGE="JAVAScript">
      if (top.areaApplication != undefined)
      {
        alert("Sessione utente scaduta. Effettuare il logon");
        top.areaApplication.location = "/gesi/online/root/login.htm";
      } 
    </SCRIPT>
    <h2>Sessione scaduta, Effettuare il logon.</h2> 
  </body>   
</html>

どうすれば正しい結果を得ることができますか? ありがとうございました!

応答を取得して出力するための私のコード: 例 1:

URL url = new URL("http://gesi-ro-test.banat.enelro:8010/dynamic/gesi/ri/elab/phonerequest/wind.serid=008201dfa306f4a2&nr=06648624&is=2011/04/20%2013:03:03.296&rt=RE/");
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));

String inputLine;
while ((inputLine = in.readLine()) != null)
      System.out.println(inputLine);
in.close();

例 2:

URL url = new URL("http://gesi-ro-test.banat.enelro:8010/dynamic/gesi/ri/elab/phonerequest/wind.ser?id=008201dfa306f4a2&nr=06648624&is=2011/04/20%2013:03:03.296&rt=RE");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
InputStream stream = connection.getInputStream();

BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
StringBuilder sb = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
    sb.append(line).append("\n");
}
stream.close();
System.out.println(sb.toString());
4

1 に答える 1

0

特定の言語を話さずに、情報にアクセスする前にサービスにログインする必要があるようです。

于 2012-08-20T08:30:25.903 に答える