java.io.IOException: Server returned HTTP response code: 411
This is because some Web servers will reject a request made to the Web server using HTTP POST without providing the appropriate BODY data. We can see the official story disseminated in explanation of the error code 411 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) :
10.4.12 411 Length Required
The server refuses to accept the request without a defined Content- Length. The client MAY repeat the request if it adds a valid Content-Length header field containing the length of the message-body in the request message.
The solution is to set content-length =0 in the request header and write an empty BODY data into the OutputStream.
URL the URL = new URL (” http://www.webservicex.net/MortgageIndex.asmx/GetCurrentMortgageIndexByWeekly “);
final HttpURLConnection conn = (HttpURLConnection) url.openconnection ();
conn. SetDoInput (true);
conn. SetDoOutput (true);
conn. SetRequestMethod (” POST “);
conn. SetRequestProperty (” the content-type “, “text/XML”);
conn. SetRequestProperty (” the Content – Length “, “0”);
DataOutputStream OS = new DataOutputStream(conn. GetOutputStream ());
OS. Write (“. “getBytes (” utf-8″), 0, 0).
OS. Flush ();
OS. The close ();
conn. The connect ();
InputStream is = conn. GetInputStream ();
Integer code = conn. GetResponseCode ();
final String contentType = conn. GetContentType ();
System. Out. Println (code + + contentType “:”);
Read More:
- What about ibtool failed with exit code 255? processing method
- Processing method of eslint verification error
- An Ajax HTTP error occurred in drupal7 installation occurred.HTTP Result Code
- Flash back after vs compiler running, processing method
- Processing method of PIP exception no module named ‘pip’
- The processing method after deleting idea’s. IML file by mistake
- [How to Solve] ashx Http Delete method not allowed
- JMeter running error response code: non HTTP response code: java.lang.illegalargumentexception find and solve
- Asynchronous Future Parallel processing request code example
- HTTP 405 Error: Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
- Processing method of SVN error “failed to run the WC DB work queue associated with…”
- HTTP error code compact version
- HTTP error 405.0 – method not allowed solution for put and delete operations of rest Service on iis7.5
- HTTP load failed, 0/0 bytes (error code: -1003 [10:-72000])
- SteamVR error code 108/203/208/301/306/308/400/405 troubleshooting method
- git clone prompt error: RPC failed result=22, HTTP code = 404 problem
- Solve the problem of “error msb6006: link.exe Exited, bad method with code 2
- python: HTTP Error 505: HTTP Version Not Supported
- ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS sqlState
- TCP error code 10061: unable to connect because the target machine actively refused http://localhost :8732/Design_ Time_ Addresses/TeacherHelperServic