简体   繁体   English

从Java类中依次调用url以进行登录,并从另一个进行web服务调用

[英]calling url from java class one after another one for logging in and another for web service call

I am able to log in to pentaho user console by calling 我可以通过调用登录pentaho用户控制台

protocal&hostname/pentaho/j_spring_security_check?j_username=joe&j_password=password

from java class after that I want to call web service call with url protocal&hostname/pentaho/SolutionRepositoryService?component=createNewFolder&solution=New_Report&path=&name=suzy_reports&desc=suzy_reports that java class itself but on calling second url it's giving 从Java类开始之后,我想使用url protocal&hostname/pentaho/SolutionRepositoryService?component=createNewFolder&solution=New_Report&path=&name=suzy_reports&desc=suzy_reports该Java类本身的Web服务调用,但是在调用第二个url时

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 401 for URL: protocal&hostname/pentaho/Login;jsessionid=F096F1C25268
D1A795A55892511D6506

but both url are working alone fine 但两个网址都可以正常工作

-is there any way to have single url for both calls? -有没有办法让两个电话都使用单个网址? -calling first url and having session stored so that it doesn't ask for authentication for second? -调用第一个url并存储会话,以便它不要求第二个进行身份验证? or any other solution? 或其他解决方案?

401 mean Unauthorized. 401表示未经授权。

I think you need to support session at your side. 我认为您需要在您身边支持会议。 After authorisation server create a session your client does not support. 授权服务器创建会话后,您的客户端不支持。

You can try use HttpClient - it support session and cookies. 您可以尝试使用HttpClient-它支持会话和cookie。

  1. Do first call with HttpClient to autorize (will create a session and put cookies values) 首先与HttpClient进行通话以进行授权(将创建一个会话并放置cookie值)
  2. Do second call with same HttpClient instance 使用相同的HttpClient实例进行第二次调用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM