我正在尝试获取您在检查网页时使用的sessionid
Cookie。例如,在Chrome上右键单击页面>检查>网络> (用F5刷新)
我正在尝试使用URLConnection库:
URLConnection connection = new URL("http://website.com/link/to/some_wsdl?wsdl").openConnection();
connection
内的字段如下:
请求:
keys:
0 = "GET /link/to/some_wsdl?wsdl HTTP/1.1"
1 = "User-Agent"
2 = "Host"
3 = "Accept"
4 = "Connection"
values:
1 = "Java/1.8.0_131"
2 = "iccdev.ejgallo.com"
3 = "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
4 = "keep-alive"
响应:
keys:
1 = "Date"
2 = "Server"
3 = "X-Powered-By"
4 = "Keep-Alive"
5 = "Connection"
6 = "Transfer-Encoding"
7 = "Content-Type"
8 = "Content-Language"
values:
0 = "HTTP/1.1 200 OK"
1 = "Tue, 20 Jun 2017 00:35:53 GMT"
2 = "Oracle-Application-Server-11g"
3 = "Servlet/2.5 JSP/2.1"
4 = "timeout=5, max=100"
5 = "Keep-Alive"
6 = "chunked"
7 = "text/xml; charset=utf-8"
8 = "en"
问题是我错过了一个sessionid条目,该条目应位于前缀为distsite=SESSIONID=
的请求标头中
基本上,我正在寻找的cookie是我们的自定义LDAP实现内部使用的cookie,它只能通过使用所述LDAP实现进行身份验证来创建。 cookie用于SSO(单点登录),因此浏览器可以通过标准协议轻松获取。由于我在没有正确身份验证的情况下使用Java来获取它,因此我不会在调用LDAP API的响应中返回cookie。
答案 0 :(得分:0)
Cookie在JSESSIONID
下键入,因此请像这样检索
String sessionId = connection.getHeaderField("JSESSIONID");