0

Eclipse プログラムから Web サービスを呼び出そうとしています。しかし、応答として応答コード 500 を取得しています。IE または Mozilla から URL にアクセスすると、問題なく動作します。私のサンプルEclipseプログラム:

public static void main(String[] args) {
   // Use apache commons-httpclient to create the request/response
   HttpClient client = new HttpClient();
   Credentials defaultcreds = new UsernamePasswordCredentials("aaa", "aaaa");
   client.getState().setCredentials(AuthScope.ANY, defaultcreds);

   GetMethod method = new GetMethod("http://localhost:8080/usersByID/2039");
   try {
      client.executeMethod(method);
      InputStream in = method.getResponseBodyAsStream();
      // Use dom4j to parse the response and print nicely to the output stream
      BufferedReader reader = new BufferedReader(new InputStreamReader(in));
      StringBuilder out = new StringBuilder();
      String line;
      while ((line = reader.readLine()) != null) {
         out.append(line);
      }
      System.out.println(out.toString());
   } catch (IOException e) {
      e.printStackTrace();
   }
}

IE または Mozilla でリンクを開くと、正確な出力が得られます。資格情報は正しいです。

これを克服するのに役立つ人はいますか。

ありがとう。

4

0 に答える 0