apache-httpclient-4.x

Sending file to secured SOAP web service using apache http client

我是研究僧i 提交于 2020-01-16 07:18:49
问题 There is a SOAP service written which is for any file transfer. I need to call that service using apache http client library. First thing to be noted is that the service is secured with password digest. I have username and password. Second, I need to pass a file as an attachment. I have come across the following code void post(String strURL, String strSoapAction, String strXMLFilename) throws Exception{ File input = new File(strXMLFilename); PostMethod post = new PostMethod(strURL);

Uploading file in a https url in post method - java.io.IOException: Error writing to server - Java

谁说我不能喝 提交于 2020-01-15 23:41:14
问题 I have to upload a binary image file to the server using multi-part, I open the connection to the https url and write diretly to to the outputstream. I have tried the SSLSocket, apache http client, but in all ways I get the error message, java.io.IOException: Error writing to server. I have to write post params with the multi-part binary file. The code is given below, where am I failing to see the mistake in this code below? And, I have given the sample data to write the data to the

How to set HTTP headers on Camel http4 endpoint

百般思念 提交于 2020-01-15 09:10:23
问题 How does one set the headers for a request made using the http4 component in Camel? The site I'm connecting to requires the referrer header to be set. Using HttpClient directly, one can add headers to the request, but I can't see how that's exposed in Camel. ETA: Working example based on the accepted answer: from("timer://foo?fixedRate=true&delay=0&period=300000") .setHeader("Referer", constant("https://example.com")) .to("https4://www.example.com") 回答1: You should just be able to set it as a

No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)) httpclient

半城伤御伤魂 提交于 2020-01-14 14:12:11
问题 I am trying to download pdf file from server using http client using ntlm Auth Scheme. but I am getting below error when. The file is getting downloaded when I used wget with username and password as parameters but if I use same username and password it fails with 401 using java code. I am using httpclient 4.2.2 Authentication error: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)) Below is my code to download

The API package 'remote_socket' or call 'Resolve()' was not found - GAE Java

北慕城南 提交于 2020-01-11 13:54:11
问题 I'm trying to call a Google Service in a GAE application hosted in GAE cloud: private String doPost(String URL) throws ClientProtocolException, IOException { // Params: List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("accountType", "HOSTED_OR_GOOGLE")); params.add(new BasicNameValuePair("Email", _DEFAULT_USER)); params.add(new BasicNameValuePair("Passwd", _DEFAULT_PASS)); params.add(new BasicNameValuePair("service", "ah")); // Call HttpClient

How do I replace Deprecated httpClient.getParams() with RequestConfig?

僤鯓⒐⒋嵵緔 提交于 2020-01-10 12:03:15
问题 I have inherited the code import org.apache.http.client.HttpClient; ... HttpClient httpclient = createHttpClientOrProxy(); ... private HttpClient createHttpClientOrProxy() { HttpClient httpclient = new DefaultHttpClient(); /* * Set an HTTP proxy if it is specified in system properties. * * http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html * http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientExecuteProxy.java */ if(

java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE

核能气质少年 提交于 2020-01-09 22:37:08
问题 Good day! I need help! I develop app for android with integration the IIS(SharePoint). And when i run this code(Code 2), i get ERROR java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE I run this code in firstActivity in method onCreate(Code 1) Version httpclient - 4.3; Code 1 new Thread(new Runnable() { @Override public void run() { new HttpsClietn(); } }).run(); Code 2 package com.example.HttpsMy; import android.os.Environment; import org.apache.http.auth

Setting socket buffer size in Apache HttpClient

我们两清 提交于 2020-01-07 02:33:07
问题 How do you set the socket buffer size in Apache HttpClient version 4.3.3? 回答1: HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 128 * 1024); HttpPost post = new HttpPost(url); String res = null; try { post.addHeader("Connection", "Keep-Alive"); post.addHeader("Content-Name", selectedFile.getName()); post.setEntity(new ByteArrayEntity(fileBytes)); HttpResponse response = client.execute(post); res = EntityUtils.toString

httpcomponents not working as documented

不羁的心 提交于 2020-01-06 08:33:10
问题 Using the code I found here: http://hc.apache.org/httpcomponents-client-ga/quickstart.html I created a quick HTTP client application. Here is a code snippet: DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); log.info("Logging in"); HttpResponse response; try { response = httpclient.execute(httpGet); } catch (ClientProtocolException cpe) { String msg = "Error logging in with:" + rootUrl; log.error(msg, cpe); throw new BusinessRuleException(msg, cpe); }

How to construct JSON data in Java [closed]

社会主义新天地 提交于 2020-01-06 08:16:42
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 months ago . I would want to POST JSON request using Apache HttpClient. But the Json data is little complex that I would want to send to target system. Below is the json that I would send { "name":"xyz", "id":"428", "mailId": [ "mailme@mail.com" ], "bundle1": { "opwarden": { "number":