We getting a SSO request using Ping Identity Federation server which opening target URL with a post of opentoken as form data. But at my application I am getting two request one is 302 Found where I can see form data in headers but after that it issue a 200 request in which data is not there.
Is this normal if yes how to get formdata?
Just curious for this behaviour....I can still access that data from referrer header information.
I am using java/jsp.
It was actually coming in request body which need to be read using getReader. that's why it redirecting again to 200 as in first request I was consuming parameter instead of body.
Related
Some third party is sending an Http Post request whenever something changes in their DB (e.g. when a contact has been updated, they send the contactID and 'contact_updated'). I have build a socket listener that catches those requests and is able to parse the information. However, I just can't get it to work to send back a response with the status '200 - OK'. Thus, the server on the client side keeps on trying (four times or so) to re-send the request.
Is there any, simple way to just send the response status without the need of adding external libs etc.?
It should be enough to send the string HTTP/1.1 200 OK back in your socket-listener.
If you have troubles, you can check out this answer, it shows how to use a HttpServer in Java just via plain JavaSE features.
Use
response.setStatus(HttpServletResponse.SC_OK);
to set the status code in your response header.
You may also set the content type.
response.setContentType("text/html;charset=UTF-8");
I'm trying to read a JSON response from a RESTful webserver running on an IoT module (Advantech WISE-4012). According to the documentation, any GET request should be made in this form
GET /ai_value/slot_0/ch_0
Any Java implementation of GET requests (Java libraries, Apache etc.), anyway, append to the end of the request the protocol signature HTTP/1.1. E.g:
GET http://192.168.0.14/ai_value/slot_0/ch_0 HTTP/1.1
Because of this (probably) i'm getting Error 400 (Bad request) on every client i tried so far. The only working method i've discovered was sending a simple request through the address bar on Google Chrome browser (sometimes i get a response, sometimes a get a bad request error either). How can i write a java implementation of a GET request plain and simple as described by the documentation? How can i test a custom GET request without HTTP/1.1 at the end? Every chrome extension i tried (Advanced REST Client, Postman) add the protocol version at the end, so i haven't had the chance to verify if that's why i'm getting a bad request error.
EDIT:
This is the response header from Advanced REST client
Connection: close
Content-Type: application/json
Server: WISE-4000/8.1.0020
While the source message is the following one:
GET /ai_value/slot_0/ch_0 HTTP/1.1
HOST: 192.168.0.14
The only mismatch between the documentation is the HTTP/1.1 signature as mentioned before. Adding the "accept: application/json" makes no difference either
After a bit of digging into the documentation, it looks like the default timeout (i.e. 720 seconds) is the one causing an issue. There doesn't seem to be any way to work it around (ideally, the system should reset the time after a successful request and we should only get 400 - or 403 ideally after 720 seconds of inactivity).
A couple of points I would like to recommend to the API developers for WISE-4012 (if they are in touch with you):
Add brief documentation for authentication and timeout (probably, more response codes and error messages with each error response)
Enable OAuth for API Access
As far as current implentation is conerned, I guess you need to do a basic auth and pass username/password with every request, Or add Authentication header with every API request to get successful response without any 400s.
Check if this helps.
HttpClient httpClient = HttpClients.createDefault();
URI reqUri = new URI(<uri>);
RequestBuilder requestBuilder = RequestBuilder.create("GET");
requestBuilder.setUri(reqUri);
requestBuilder.setHeader(<headerKey>, <headerValue>);
requestBuilder.setEntity(<entity_data>);
HttpUriRequest httpRequest = requestBuilder.build();
httpResponse = httpClient.execute(httpRequest);
If I send a request with the header like as below .,
<S:Header>
<ns2:transId xmlns="http://test.ws.com/testws"
xmlns:ns2="http://test.db.com/db9">123ASD89EDFE7363</ns2:transId>
</S:Header>
its working fine for success responses also there is no unnecessary namespace exist in the header. But error cases, the response from the web service is sent with the two namespaces using same default identifiers for the header element as like below.,
<S:Header>
<transId xmlns="http://test.ws.com/testws"
xmlns="http://test.db.com/db9">123ASD89EDFE7363</transId>
</S:Header>
because of the above format, the client application is unable to parse the responses.
the client artifact is generated using the clientgen from the wsdl. can anyone please help to find the resolution for the above issue.
Thanks in advance.
Can you describe the issue a little more?
It sounds like you're making an HTTP request with a header that has the value "123ASD...", and that when the server responds with OK (200) then it works as expected, but that when the server responds with an error condition (4xx-5xx) then the response it bad.
is it duplicating the same header twice in the HTTP response headers?
Or is it sending an extra request (like perhaps a redirect)?
Like
GET gets a 301 repsonse with the header and then maybe it sends to an error page but it uses the same header twice or something?
A little more information about the header value (does it change every time?) might help...
Thanks for your response. its a SOAP message with header and body over HTTP and there is no issues with the HTTP. error response is like the soap fault or schema validation error from the server when we send bad soap requests. Its not duplicating the header, but when a soap request sent with the unnecessary namespace xmlns="http://test.ws.com/testws" (it has nothing to do with the header elements but my client app adds this everytime when it sends request ), the web service returns the response including the above one and the needed namespace of xmlns="http://test.db.com/db9". my question is the web service is not using different identifiers when it sends two namespaces. the header value is static during one transaction like sessionid.
I have the following situation that I'm still not able to manage:
I wrote a java class to read a http response from a site that receive POST parameters
I use HttpURLConnection and pass the input parameters
the result obtained is another form that redirect to another page (via HTTPS) to which I have to pass a username and a password and an hodden value. this page show the result in a target page (that is the firt url)
I made a call to this other page via HTTPS (HttpsURLConnection) and obtained a http 302 response code
I'm not able to reach the result page, since the followredirect option doesn't work when the protocol change (from http to https)
Can anyone help me please?
Hope I have succesfully explained.
Thanks in advance for support and regards.
I am trying to set up a http responder for incoming GET requests using a JSP page with a SimpleFormController.
I am receiving a GET request from a third party company, who are expecting a 200 http response back. However, even though my JSP is basically blank, when a GET request come in, it bypasses my JSP page and is automatically submitted to the onSubmit method in my controller and a http response of 201 is sent back.
How can I send a 200 response back, instead of 201?
Thanks,
Dave
If the onsubmit method is being called, it sounds to me like they are not sending a get request, but doing a post.
Make sure they are sending a get request.