Inspect REST request and response generated by jersey and jaxb - debugging

I have a method:
#PUT
#Consumes(MediaType.APPLICATION_XML)
#Produces(MediaType.TEXT_PLAIN)
public String createQueue(JAXBElement<Queue> queueElement) {
// do some stuff here
return "";
}
Now, when I call this service from my client java application, I would like to inspect the HTTP request that has been created. I want to see the XML (request body) that is created by jaxb. Is there a tool that can observe requests / responses that are made on a particular URL?
Thanks in advance, Andreas

You can use a simple program that will act as a proxy and display the HTTP requests. There are plenty out there. Since you are using Java I suggest a simple TcpMon. If you use soap a lot also, you can use the built in monitor in soapui. If you also want to watch traffic from your browsers, you might consider fiddler.

For that I would use Firefox + Firebug, which has nice network panel.

Charles has a much better UI than Fiddler
Charles and Fiddler are proxy debuggers.
If you just want to sniff the http traffic I recommend Wireshark since it sniff the traffic at the Ethernet level and there is no proxy settings to change

Related

PostCatcher Equivalent For Https?

I have been using postcatcher.in to test my HTTP post requests. But, I have no been able to find an equivalent service which supports HTTPS. Does anyone knows of something like that?
Beeceptor - can help you. It is real-time and supports HTTPs.
Request payload inspection
Mocking the response when a request path matches
(Disclaimer: I am the author and developed this as a need to proxy requests to an HTTP endpoint and still want to mock a few requests)

How to see all HTTP Get request sent from browser without debugging tool?

so, I have page doing a number of ajax and jsonp(i.e. injection) to get data. I would like to know how to find out the request URL I have made without using debugging tools, like firebug. etc. i.e. the history of GET request of the browser. Thanks
For the most part, browsers do NOT log a history of their HTTP GET requests. Also, if you're using ajax, you're probably doing HTTP POST requests as well.
You don't have to use an in-browser tool like Firebug, but you will need some tool to actually get a history of requests and the request bodies.
You can use a tool like Fiddler2, which is a proxy that gets all HTTP traffic outgoing from your computer (including from your browser and all other applications).
If you have control of the server environment, you can also set up logging on the server to capture this data.
You can use WireShark or a similar tool to monitor the network traffic and inspect the packets.

view response content of ajax,flash http requests

I'm interested if there is some tool (preferably a firefox addon) that allows you to record http requests and view their response header and content.
Try HttpFox :
HttpFox monitors and analyzes all
incoming and outgoing HTTP traffic
between the browser and the web
servers.
It aims to bring the functionality
known from tools like HttpWatch or
IEInspector to the Firefox browser.
Information available per request
includes:
- Request and response headers
Sent and received cookies
Querystring parameters
POST parameters
Response body
Firefox's firebug and webkits developer tools.
I recommend using Charles, http://www.charlesproxy.com/.
Charles is a stand-alone application, not a browser addon (but it has browser integration) which I personally prefer, since it can monitor http traffic also outside the browser, for example when a swf is run locally or from an IDE, or any other http traffic on your system.
If you prefer a browser addon, I believe Fiddler is quite popular, http://www.fiddler2.com/.

is there a way using Ruby's net/http to post form data to an http proxy?

I have a basic Squid server setup and I am trying to use Ruby's Net::HTTP::Proxy class to send a POST of form data to a specified HTTP endpoint.
I assumed I could do the following:
Net::HTTP::Proxy(my_host, my_port).start(url.host) do |h|
req = Net::HTTP::Post.new(url.path)
req.form_data = { "xml" => xml }
h.request(req)
end
But, alas, proxy vs. non-proxied Net::HTTP classes don't seem to use the proxy IP Address. my remote service responds telling me that it received a request from the wrong IP address, ie: not the proxy. I am looking for a specific way to write the procedure, so that I can successfully send a form post via a proxy. Help? :)
Hah, turns out that is the right way to do it, my issue was actually with Squid and the API I was pushing to. Interesting tip related to this problem, if you are proxying with Squid proxy server, you probably want to add this server config option:
header_access X-Forwarded-For deny all
This will make sure that the proxy completely ignores any relation to the caller's IP address as far as the HTTP endpoint is concerned.
You may also want to look at the mechanize gem, based on Perl's WWW::Mechanize. If it's anything like the Perl one (and I'm led to believe it is), then it encapsulates much of the common mess that you're dealing with.
Ruby: http://mechanize.rubyforge.org/
Perl: http://search.cpan.org/dist/WWW-Mechanize/

Modifying HTTP request and responses with a Browser Helper Object

I want to modify HTTP requests headers using an Internet Explorer Browser Helper Object.
I basically need to change a few headers for every request, and then modify the response before it returns to the browser.
I tried using the OnNavigate2 events, but those don't even give you access to all of the headers.
I tried making an Asynchronous Pluggable Protocol, but then I don't really have access to the default HTTP implementation, and i can't override the default HTTP requests.
Do you have any idea how this is supposed to be done?
I prefer C#, but could use C++ if necessary.
It can be done with URL monikers.
There is an implementation of something like that by a guy called Igor Tandetik.
You can find links to the code in: microsoft.public.inetsdk.programming google group - just look for PassthruAPP.
(I would have posted a link but apparently new users are not allowed to do this)
It doesn't directly support modifying the response body though.
You will have to insert a hook into the IInternetProtocolImpl::Read method.
The easiest way to do it is to use an http proxy to intercept everything the way Fiddler does.
See this description of the Fiddler PowerToy (Part 1).
It seems that you can only modify CUSTOM headers by using the headers parameters of the BeforeNavigate2 event. Not all the headers are accessible. This is a way to try to minimize the potential of the BHOs to act as a Trojans. Use a HTTP proxy instead.

Resources