Http Error 400 when consuming a webservice
I am consuming a webservice which is deployed in remote weblogic server from an applictaion deployed in another weblogic server. Below is the code I use
URL url = new URL(URL);
String authString = "USR_NM:PWD";
String encodeingUserPwd = new BASE64Encoder().encode(authString.getBytes());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Authorization", "Basic " + encodeingUserPwd);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
OutputStream os = conn.getOutputStream();
os.write(JSONREQUEST.getBytes("UTF-8"));
os.close();
InputStream content = (InputStream)conn.getInputStream();
String jsonString = IOUtils.toString(content, "UTF-8");
The above code works and I am able to consume the service for some time. But after some time I get the below error.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.<br />
<pre>
ECID-Context
</pre>
</p>
</body></html>
I don't send any thing other than this in request header. Also remote server is up and I am able to get the response when I tried in Postman.
If this is because of bad request, then I am able to get it working for few request. I am confused with what is causing this issue ? Any help is appreciated.
java rest weblogic
add a comment |
I am consuming a webservice which is deployed in remote weblogic server from an applictaion deployed in another weblogic server. Below is the code I use
URL url = new URL(URL);
String authString = "USR_NM:PWD";
String encodeingUserPwd = new BASE64Encoder().encode(authString.getBytes());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Authorization", "Basic " + encodeingUserPwd);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
OutputStream os = conn.getOutputStream();
os.write(JSONREQUEST.getBytes("UTF-8"));
os.close();
InputStream content = (InputStream)conn.getInputStream();
String jsonString = IOUtils.toString(content, "UTF-8");
The above code works and I am able to consume the service for some time. But after some time I get the below error.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.<br />
<pre>
ECID-Context
</pre>
</p>
</body></html>
I don't send any thing other than this in request header. Also remote server is up and I am able to get the response when I tried in Postman.
If this is because of bad request, then I am able to get it working for few request. I am confused with what is causing this issue ? Any help is appreciated.
java rest weblogic
Could you hold on to recent request headers until you get the response and dump them - just for troubleshooting to see if any of them are really big. The only one I guess could become big is the Authorization header depending on what you get from the authString.. Or if this happens frequently enough, have network capture running until you get a 400, and correlate the request see if you get any clues from that (eg what is actually sent on the wire). If your side looks ok, maybe it's an error on server side, and a network capture can be good to have when communicating to server folks.
– daljian
Nov 21 '18 at 8:24
add a comment |
I am consuming a webservice which is deployed in remote weblogic server from an applictaion deployed in another weblogic server. Below is the code I use
URL url = new URL(URL);
String authString = "USR_NM:PWD";
String encodeingUserPwd = new BASE64Encoder().encode(authString.getBytes());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Authorization", "Basic " + encodeingUserPwd);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
OutputStream os = conn.getOutputStream();
os.write(JSONREQUEST.getBytes("UTF-8"));
os.close();
InputStream content = (InputStream)conn.getInputStream();
String jsonString = IOUtils.toString(content, "UTF-8");
The above code works and I am able to consume the service for some time. But after some time I get the below error.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.<br />
<pre>
ECID-Context
</pre>
</p>
</body></html>
I don't send any thing other than this in request header. Also remote server is up and I am able to get the response when I tried in Postman.
If this is because of bad request, then I am able to get it working for few request. I am confused with what is causing this issue ? Any help is appreciated.
java rest weblogic
I am consuming a webservice which is deployed in remote weblogic server from an applictaion deployed in another weblogic server. Below is the code I use
URL url = new URL(URL);
String authString = "USR_NM:PWD";
String encodeingUserPwd = new BASE64Encoder().encode(authString.getBytes());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Authorization", "Basic " + encodeingUserPwd);
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
OutputStream os = conn.getOutputStream();
os.write(JSONREQUEST.getBytes("UTF-8"));
os.close();
InputStream content = (InputStream)conn.getInputStream();
String jsonString = IOUtils.toString(content, "UTF-8");
The above code works and I am able to consume the service for some time. But after some time I get the below error.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.<br />
<pre>
ECID-Context
</pre>
</p>
</body></html>
I don't send any thing other than this in request header. Also remote server is up and I am able to get the response when I tried in Postman.
If this is because of bad request, then I am able to get it working for few request. I am confused with what is causing this issue ? Any help is appreciated.
java rest weblogic
java rest weblogic
asked Nov 21 '18 at 8:12
MojoyMojoy
10.5k3284128
10.5k3284128
Could you hold on to recent request headers until you get the response and dump them - just for troubleshooting to see if any of them are really big. The only one I guess could become big is the Authorization header depending on what you get from the authString.. Or if this happens frequently enough, have network capture running until you get a 400, and correlate the request see if you get any clues from that (eg what is actually sent on the wire). If your side looks ok, maybe it's an error on server side, and a network capture can be good to have when communicating to server folks.
– daljian
Nov 21 '18 at 8:24
add a comment |
Could you hold on to recent request headers until you get the response and dump them - just for troubleshooting to see if any of them are really big. The only one I guess could become big is the Authorization header depending on what you get from the authString.. Or if this happens frequently enough, have network capture running until you get a 400, and correlate the request see if you get any clues from that (eg what is actually sent on the wire). If your side looks ok, maybe it's an error on server side, and a network capture can be good to have when communicating to server folks.
– daljian
Nov 21 '18 at 8:24
Could you hold on to recent request headers until you get the response and dump them - just for troubleshooting to see if any of them are really big. The only one I guess could become big is the Authorization header depending on what you get from the authString.. Or if this happens frequently enough, have network capture running until you get a 400, and correlate the request see if you get any clues from that (eg what is actually sent on the wire). If your side looks ok, maybe it's an error on server side, and a network capture can be good to have when communicating to server folks.
– daljian
Nov 21 '18 at 8:24
Could you hold on to recent request headers until you get the response and dump them - just for troubleshooting to see if any of them are really big. The only one I guess could become big is the Authorization header depending on what you get from the authString.. Or if this happens frequently enough, have network capture running until you get a 400, and correlate the request see if you get any clues from that (eg what is actually sent on the wire). If your side looks ok, maybe it's an error on server side, and a network capture can be good to have when communicating to server folks.
– daljian
Nov 21 '18 at 8:24
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407703%2fhttp-error-400-when-consuming-a-webservice%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407703%2fhttp-error-400-when-consuming-a-webservice%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you hold on to recent request headers until you get the response and dump them - just for troubleshooting to see if any of them are really big. The only one I guess could become big is the Authorization header depending on what you get from the authString.. Or if this happens frequently enough, have network capture running until you get a 400, and correlate the request see if you get any clues from that (eg what is actually sent on the wire). If your side looks ok, maybe it's an error on server side, and a network capture can be good to have when communicating to server folks.
– daljian
Nov 21 '18 at 8:24