java - Server Not Responding Using Put method with Spring web client -
So I'm trying to upload the file using the method put on my server. I am experiencing some strange behavior using the Spring Web Client, the following code is mine
// Setup Properties String publishUrl = "http: // localhost: 8080 / url / To / rest / api "; File schema file = new file ("myFile.xml"); String catalog = "myFileName"; String jndiName = "myJNDI"; Boolean overwrite = true; Boolean enabled xxml = true; // Setup Form MultivallMap & lt; String, Object & gt; Form = New LinkedIn Value Value & lt; String, Object & gt; (); Form.add ("uploadAnalysis", New FileSystemResource (SchemaFile)); Form.add ("catalogName", catalogname); Form.add ("data source", jndiName); Form.add ("overwrite", overwrite? "True": "wrong"); Form.add ("xmlaEnabledFlag", enableXmla? "True": "false"); Form.add ("parameter", "data source =" + jndiName); // Set credentials credentialsProvider credsProvider = new BasicCredentialsProvider (); Credsprovider.setCredentials (AuthScope.ANY, New username password credentials ("Admin", "Password")); // Set Up http Client CloseableHttpClient httpclient = HttpClients.custom () SetDefaultCredentialsProvider (credsProvider) .build (); // http http: //http; http: // http; http: // httphttp; http: // http; HTTP; http: // http; http: // http; http: // http; http: // http; HTTP requests; // RestTemplate RestTemplate RT = New RestTemplate (Fact); // html headers html headers to create // new html header (); Headers.setContentType (MediaType.MULTIPART_FORM_DATA); // Use method HttpEntity & lt; MultiValueMap & lt; String, Object & gt; & Gt; Unit = new HttpEntity & lt; MultiValueMap & lt; String, Object & gt; & Gt; (Form, headers); ResponseEntity & LT; String & gt; Feedback = rt.exchange (publishUrl, HttpMethod.PUT, unit, String.class);
This works, my files are uploaded to the server. However, I did not receive any response from the server, I always get the following exception:
I used the first jersey and always received a response But for this purpose, I need to use spring. I was curious if there are no headers or other properties that I received a response. Must set up? Thanks!
Comments
Post a Comment