Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Spring RestTemplate中旋转卷曲_Spring_Curl_Command_Resttemplate - Fatal编程技术网

在Spring RestTemplate中旋转卷曲

在Spring RestTemplate中旋转卷曲,spring,curl,command,resttemplate,Spring,Curl,Command,Resttemplate,我有点困惑 我试图重写以下curl命令: http://:/solr/test2\u shard1\u replic1/update?commit=true-H“内容类型:text/xml”--数据二进制“111alphadevx” 使用StringFramework RestTemplate类和方法postForObject(url、请求、响应类), 但是没有运气。我的意思是,看起来,请求正常,但在SolrCloud中绝对没有效果 代码如下: MultiValueMap<String,

我有点困惑

我试图重写以下curl命令: http://:/solr/test2\u shard1\u replic1/update?commit=true-H“内容类型:text/xml”--数据二进制“111alphadevx”

使用StringFramework RestTemplate类和方法postForObject(url、请求、响应类), 但是没有运气。我的意思是,看起来,请求正常,但在SolrCloud中绝对没有效果

代码如下:

MultiValueMap<String, Object> requestMap = new LinkedMultiValueMap<>();
requestMap.add("Content-Type", "text/xml");
requestMap.add("data-binary", dataToSend);

String sentData =      restTemplate.postForObject("http://<solr_server>:<solr_port>/solr/test1_shard1_replica1/update?commit=true",     requestMap, String.class);
MultiValueMap requestMap=新链接的MultiValueMap();
add(“内容类型”、“文本/xml”);
add(“数据二进制”,dataToSend);
String sentData=restemplate.postForObject(“http://:/solr/test1\u shard1\u replic1/update?commit=true”,requestMap,String.class);
有错误吗

非常感谢您的建议,我收到了

以下是正确的方法:

HttpHeaders headers = new HttpHeaders();
headers.setContentType(org.springframework.http.MediaType.TEXT_XML);
HttpEntity<String> entity = new HttpEntity<>(dataToSend, headers);
ResponseEntity<String> sentData = restTemplate.exchange(((shardAddress == null ? ("http://" +     this.address + ":" + this.port + "/solr") : (this.shardAddress))) + "/test1_shard1_replica1/update?commit=true", HttpMethod.POST, entity, String.class);
HttpHeaders=newhttpheaders();
headers.setContentType(org.springframework.http.MediaType.TEXT\uXML);
HttpEntity=新的HttpEntity(dataToSend,标题);
ResponseEntity sentData=restTemplate.exchange((shardAddress==null?((http://“+this.address+”:“+this.port+”/solr”):(this.shardAddress))+“/test1\u shard1\u replic1/update?commit=true”,HttpMethod.POST,entity,String.class);