Add request header field to JMeter WebService(SOAP) Request - java

It seems like the WebService(SOAP) Request of JMeter does not include headers in the request defined in a HTTP Header Manager.
I want to send Accept-Encoding: gzip, deflate with every SOAP request of my JMeter test - is there a way to achieve that?

The workaround for me was to use the SOAP/XML-RPC Request Sampler instead of the the WebService(SOAP) Request. This one sends the configured request headers to the server.
After that I found out that the incoming compressed response was not decompressed so I filed a bug at https://issues.apache.org/bugzilla/show_bug.cgi?id=48542 and created a patch. The bug is fixed in the trunk and should be included in the current nightly build.

Related

Photo Upload - Jmeter - {"reason":"Chunk-Length mismatch (found: 73800, required:73581)"}

I am trying to upload photo via Jmeter, below is the sample request:
URL: https://domain/.../signedresources/604a9230-..../resumable?region=US
Method: PUT
Headers:
Content-Type - image/jpeg, image/jpeg
Session-Id - 884b03...
Content-Range - bytes 0-73580/73581
Content-Length - 73581
In File Upload tab of Jmeter I have checked: Use Multipart/form-data option
File Path: /Users/sujata.../Downloads/fish.jpeg
Parameter Name: file_upload[]
MIME type: image/jpeg
Now, this request works fine when executed via Postman, and in Postman Content-Length 73581 header is not passed. The file size in bytes is 73581. However while running this request via jmeter Content-Length - 73581 header is automatically added and everytime the value is different, which is ending up with below error:
{"reason":"Chunk-Length mismatch (found: 73800, required:73581)"}
Is there any way to compute the content-length of file which we are going to upload and pass that value in the header?
I also tried explicitely mentioning Content-Length - 73581 in header but still it is not taking this valued and somehow some new value is computed and mismatch error is shown.
Is there any way to bypass this content-length computation by jmeter, or overwrite?
PUT-Request-Jmeter
Content-Type_header_added_by_jmeter
Content-Length header stands for the number of bytes in the request body. The request body begins right after the Headers. So if you're uploading just one file and there are no dynamic parts of the request - it should be the same every time you execute the request. However for multipart requests you have the boundary which is random and its length may vary, that explains the eventual differences.
It might be the case Postman sends the file in "raw" mode, i.e. not multipart. In this case you will need to untick Use multipart/form-data box in the HTTP Request sampler.
Going forward if you're able to successfully run the request using Postman you can just record it with JMeter's HTTP(S) Test Script Recorder
Start JMeter's HTTP(S) Test Script Recorder
Import JMeter's certificate into Postman
Configure Postman to use JMeter as the proxy
Copy the file you will be uploading to the "bin" folder of your JMeter installation
Run your request in Postman
That's it, now you should have appropriate JMeter configuration for the file upload.
More information: How to Convert Your Postman API Tests to JMeter for Scaling

HTTP Status 405 - Request method 'POST' not supported in jmeter

I have recorded a script and running it. But I'm receiving the following error.
HTTP Status 405 - Request method 'POST' not supported in jmeter
I'm not sure whether it is script issue or coding issue.
Our application is installed on HTTPS but security certificate not yet installed.
Could any one please help me out.
It could be one of below
The endpoint you are requesting is not supported for POST, It may support only GET, Please change the method in Jmeter to GET or the method your url supports
The endpoint may expect proper CSRF token. It might mismatch with one you recorded. So Please extract CSRF token from previous request's response and use it. You can do via RegEx Extractor in Jmeter.
JMeter does support POST method so it may be due to:
Endpoint you're using doesn't support POST method (it expects other method(s) like GET, PUT, DELETE, etc.)
You're sending not properly configured request.
The most common reason is missing relevant Content-Type header. You can use HTTP Header Manager in order to send the relevant Content-Type header which is usually application/json for REST or text/xml or similar for SOAP.
See Testing SOAP/REST Web Services Using JMeter article for more information on API testing using JMeter.
You can also consider the following approach:
Use specialized Web Services testing tool like SoapUI or RESTClient to fire a request
Either use aforementioned tool or 3rd-party sniffer like Wireshark to capture the request
Configure JMeter to send exactly the same request

how to check response header from apache

When a request is coming in, it goes through apache sever before going to application server written in tomcat. In most cases, I can set the response header from apache server to return a certain response header like x-frame-options. However, depending on the page and requester, I would like to remove this x-frame-options in the apache layer.
So far, I tried following two options, but both did not work.
apache always set the header to generic, but application server override it to something else based on the condition.
apache Httpd.conf: Header always append X-Frame-Options SAMEORIGIN
Java Code: response.setHeader("X-FRAME-OPTIONS", "DENY");
application server set to something else then apache to check the header before setting to generic.
Java Code: response.setHeader("X-FRAME-OPTIONS", "DENY");
apache httpd.conf: RequestHeader set X-Frame-Options "SAMEORIGIN" env=no_my_header
I don't know what to do at this point. If anyone has any idea, I would appreciate.
Thanks,

Remove unnecessary HTTP headers using apache

I have a requirement in my application where a header other than default one sent in http request should be suppressed. Right now in my application when i send a request i am able to attach custom header fields.
Is there a way in apache tomcat configuration settings which will suppress headers other than default ones ? , i tried checking few sites, i found how to remove headers in response
http://www.shanison.com/2012/07/05/unset-apache-response-header-protect-your-server-information/
Is there any similar solution to remove request headers?
Thanks in adv.

glassfish response not getting in gzip compressed

i am working on java with Netbeans IDE and glassfish 3.1.2 i have created in rest services using jaxrs. when request from client is made ,i need to send json data in compressed format.to do this i have enabled the compression in glassfish as shown the following picture
but response got from the server is not compressed using gzip. it is receiving as normal json data. what should i do to overcome this issue
This is a solution for GF 3.1.2.2.
Responses to HTTP requests in version 1.0 are not compressed. You must send your requests in HTTP 1.1 to get gzipped responses from your glassfish server.
More over, you must add the header "Accept-Encoding: gzip" in your http requests.
To get a compressed response you need to have both sides agree to use it. You have configured GlassFish to send compressed responses. I can see that from the picture.
You need to make sure that your request to the services tells GlassFish that it can accept a compressed response. You normally do this by adding the following header to your HTTP requests: Accept-Encoding. You can read about the header in the RFC document that defines HTTP 1.1 request headers.
You can also get a lot of info from reading though SO questions about Accept-Encoding.

Categories