Java 服务器未对SpringWeb客户端使用Put方法进行响应

Java 服务器未对SpringWeb客户端使用Put方法进行响应,java,spring,web-services,rest,Java,Spring,Web Services,Rest,因此,我尝试使用put方法将文件上载到服务器。我在使用SpringWeb客户端时遇到了一些我认为是奇怪的行为,下面是我的代码 //setup properties String publishUrl = "http://localhost:8080/url/to/rest/api"; File schemaFile = new File("myFile.xml"); String catalogName = "myFileName"; String jndiName = "myJNDI"; bo

因此,我尝试使用put方法将文件上载到服务器。我在使用SpringWeb客户端时遇到了一些我认为是奇怪的行为,下面是我的代码

//setup properties
String publishUrl = "http://localhost:8080/url/to/rest/api";
File schemaFile = new File("myFile.xml");
String catalogName = "myFileName";
String jndiName = "myJNDI";
boolean overwrite = true;
boolean enableXmla = true;

//setup form
MultiValueMap<String, Object> form = new LinkedMultiValueMap<String, Object>();
form.add("uploadAnalysis", new FileSystemResource(schemaFile));
form.add("catalogName", catalogName);
form.add("Datasource", jndiName);
form.add("overwrite", overwrite ? "true" : "false");
form.add("xmlaEnabledFlag", enableXmla ? "true" : "false");
form.add("parameters", "Datasource=" + jndiName);

//Set up credentials
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("Admin", "password"));

//set up http client
CloseableHttpClient httpclient = HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();

//create client request factory using httpcient
HttpComponentsClientHttpRequestFactory fact = new HttpComponentsClientHttpRequestFactory(httpclient);

//create rest template
RestTemplate rt = new RestTemplate(fact);

//create http headers
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);

//use put method. 
  HttpEntity<MultiValueMap<String, Object>> entity = new HttpEntity<MultiValueMap<String, Object>>(form, headers);

ResponseEntity<String> response = rt.exchange(publishUrl, HttpMethod.PUT, entity, String.class);

我以前使用过Jersey,总是会得到回复,但对于这个项目,我需要使用Spring。我很好奇是否需要设置任何标题或其他属性才能获得响应?谢谢

你能给我们看看你的服务器吗?你到底想看什么?它做什么?它可能在获取文件后崩溃,并且从未发送响应。
org.springframework.web.client.ResourceAccessException: I/O error on PUT request for "http://localhost:8080/url/to/rest/api":localhost:8080 failed to respond; nested exception is org.apache.http.NoHttpResponseException: localhost:8080 failed to respond
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:543)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:489)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:431)