How to intercept http response in Artifactory java client? - java

I need to log http response from Artifactory, I am using this https://github.com/jfrog/artifactory-client-java There is info on how to intercept and log requests, but no info on how to intercept/log responses. How can I achieve this?

Related

I want spring boot application which accepts https request and send this request to other app on http and send this http response back to https req

I tried and able to read the CA certificates succsssfully send in request. But when sending request to other app over http getting error as " This combination of host and port required TLS" . Is there any way I can send the request to http and on receiving response, send this response back to https request.
you need to enable http on the server you are sending request to.

Apache Camel HTTP Timeout

I am using Apache Camel route for HTTP call. I wanted to add timeout if there is delay from host system.
I am using the following configuration but it is not working. The client request is getting timeout without waiting host system timeout. The client timeout is configured in CXF but the camel timeout is configured in camel route. It should timeout in 4 second and it should go to error processor and but it is not happening.
HTTP
<setHeader headerName="CamelHttpQuery">
<constant>httpclient.soTimeout=4000&bridgeEndpoint=true&throwExceptionOnFailure=false</constant>
<setHeader>
HTTP4
<setHeader headerName="CamelHttpQuery"><constant>httpclient.socketTimout=4000&bridgeEndpoint=true&throwExceptionOnFailure=false</constant>
<setHeader>
Thanks
Please be attentive for syntax. Correct spelling
httpClient.socketTimeout=4000&bridgeEndpoint=true&throwExceptionOnFailure=false
But even after correcting parameters it will not work. Instead of configuring http endpoint you send your parameters as query string of request to server. For set up endpoint just add your parameters to it and use CamelHttpQuery header for request parameters.

POST payload over HTTPS connection in Spring

I am trying to connect to third party system over HTTPS connection and post parameters to receive a response. This is gonna be a POC I will be doing for which I am already started researching. I have already done a client-server TCP connection with an outbound gateway using SI in my spring application. Does SI provide a way to achieve HTTPS connection or is there any easier way, RestTemplate?
I could see Spring Integration - how to send POST parameters with http outbound-gateway, but it talks about HTTP rather than HTTPS.
Note: A linux server already communicates to this third party system using CURL. I need to replicate this communication in my spring application. Here is the sample Req / Res shared.
Request data: ord=000000&term=022&storenum=00623&fgen=667&action=1024&ctime=072119:22:23:32&tmout=08&PLU=00007565604633&BC=10364678071919225000623&QTY= 1.000
Response: 000000022006231024ctime=072119:22:23:32&itmz=P---11NSFU-T&desc=JARU ALL MN LT UP DIAMOND&rmfsline=1&avqty=1.0&barcode=10364678071919225000623&qty=1.0&rcptqty=3.0000&rcptline=5&upc=7565604633&reqqty=1.0&unitprice=1.97&price=5.91&dept=92&resp=00&POST /RMFSWeb/LineAuthListener? HTTP/1.1
Also, the URL shared with me is https://xx-cert.keb.com:20143 but this doesn't have a class/method name in the URL. Is it not required for an HTTPS connection?
Please share your thoughts on how I can achieve https connection from spring with the data above. Thanks for your help
RestTemplate with PostRequest will do all your job.
Refer an answer by 'Tharshan' in this post.
How to POST form data with Spring RestTemplate?

Apache Camel received Status 400 Bad Request from AWS VPC Endpont

I have a Java application which was built with Apache Camel. The application uses Apache Camel to construct an HTTP request to AWS VPC Endpoint.
When the Java application sends out an HTTP request, it receives HTTP Status Code 400 (Bad Request). The VPC Flow Log can be found with the traffic (correct source and destination IP addresses).
On the other hand, if we use curl command to send the same HTTP request, it turns back 200 OK.
What is a possible cause? Is there any configuration in Apache Camel to see what is the exact HTTP content or raw HTTP header/message sent out?
You could check if Content-Type and other mandatory request headers are available at Exchange.in.headers. Just log in.headers within camel-simple tag. I think 400 happening because improper content-type or bad payload.
It might be that you are sending headers that are not allowed by the API since Camel maps message headers automatically to HTTP headers.
Camel's camel-http4 component uses Apache HttpClient 4.x library and you can configure it to log raw http requests.
For instance with log4j you would add to properties:
log4j.logger.org.apache.http=DEBUG
Detailed logging options can be seen from here: https://hc.apache.org/httpcomponents-client-4.5.x/logging.html

Send HTTP response to client without having request always

My Javaserver application(Servlet) receive a service request (HTTP) from client and then it should respond to the client in fixed interval time.
How can I send HTTP response every minute to client without having a HTTP request?
have a look at https://github.com/Atmosphere/atmosphere
or Comet/WebSockets

Categories