[英]Send GET request with 443 userid password prompt authentication using Java HttpClient
I want to get the response from a url by sending url parameters(GET parameters) eg. 我想通过发送url参数(GET参数)从url获得响应。 https://ebctest.cybersource.com/ebctest/DownloadReport/2014/07/23/ $MerchantId/ConversionDetailReport.xml
https://ebctest.cybersource.com/ebctest/DownloadReport/2014/07/23/ $ MerchantId / ConversionDetailReport.xml
When I hit the server I am prompted by a userid, password dialog box. 当我点击服务器时,会出现一个用户名,密码对话框的提示。
I can get the response by manually entering the id,password. 我可以通过手动输入id,密码来获得响应。 How can I achieve this programatically using java.
如何使用Java以编程方式实现此目的。
Below is the code which I have tried till now. 下面是我到目前为止尝试过的代码。
final HttpClient httpClient = new HttpClient();
httpClient.getState().setCredentials(new AuthScope(null, 443), new UsernamePasswordCredentials(userName, password));
httpClient.getParams().setParameter("http.socket.timeout", Integer.valueOf(10000));
httpClient.getState().setAuthenticationPreemptive(true);
final GetMethod method = new GetMethod("https://ebctest.cybersource.com/ebctest/DownloadReport/2014/07/23/$merchantId/ConversionDetailReport.xml");
final InputSource is = new InputSource(new ByteArrayInputStream(method.getResponseBody()));
When I do method.getResponseBody I get empty. 当我执行method.getResponseBody时,我变得空了。 I should be getting a proper response as I am getting when sending the request manually.
手动发送请求时,我应该得到正确的响应。
it Looks like basic auth, you should be able to send username and password by calling this url: 它看起来像基本身份验证,您应该可以通过调用以下网址来发送用户名和密码:
https:// username : password @ebctest.cybersource.com/ebctest/D https:// 用户名 : 密码 @ ebctest.cybersource.com / ebctest / D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.