aspwebserviceからjavajsoupを使用していくつかの情報を取得する必要があります。私はリンクも読んだ:jsouppostingとcookie、しかし私はまだ混乱している。これが私のコードです:
//1.Create connection to server
Connection.Response res = Jsoup.connect("http://www.server.com/user.aspx?lang=en-us")
.timeout(50000).data("{\"userid\":\"subagent01\",\"password\":\"mypassword\"}", "")
.method(Method.POST)
.execute();
Map<String, String> cookies = res.cookies();
Document doc = res.parse();
//2.Get information form server
String fAddressUrl = "http://www.server.com/WebService/Service.asmx/getSchedule?fromCity=CityA&toCity=CityB";
Document doc2 = Jsoup.connect(fAddressUrl).cookies(cookies).get();
System.out.println(doc2);
そして、私はこの返事を受け取りました:
<html>
<head></head>
<body>
<string xmlns="http://tempuri.org/">
Error, session is session_expired
</string>
</body>
</html>
Webブラウザで
そのURL( " http://www.server.com/WebService/Service.asmx/getSchedule?fromCity=CityA&toCity=CityB ")
を直接呼び出そうとした場合、結果は次のようになり
ます。最初にwww.server.com-
>成功。Webブラウザで情報を取得しました
2.www.server.comでログインせずに
->失敗しました。同じエラー「エラー、セッションはsession_expiredです」を表示します。
それで、問題は何ですか?