How to test #DELETE restful service call from JMeter - web-services

I am trying to find how to issue a call to the following restful service from JMeter:
#DELETE
#Path("/user")
void removeUser(String userId);
There are plenty examples on POST, GET, but I cannot find one for delete. Specifically, I cannot find a way to pass a parameter for "userId".
Thanks

You could use #RequestParam or #PathVariable to bind the userId . You don't find many tutorial on Delete since it is not supported in earlier versions of HTML . Read this blog for more info . This is usually achieved through a hidden parameter .
Read this post Are the PUT, DELETE, HEAD, etc methods available in most web browsers? for more info .

Have you tried to record that request using jMeter Proxy?
Simply:
Add > Logic Controller > Recording Controller to your Test Plan
Add > Non-test elements > Http Proxy Server to your WorkBench
As Target controller choose your Recording controller
Set your browser proxy settings to point to your jMeter machine (usually your localhost) on standard port 8080
Click Start button at the bottom of your Http Proxy Server component
Fire that delete request in your browser
Immediately after submitting the request, stop the Http Proxy Server (to avoid recording other junk, usually ajax/refresh requests from other opened tabs)
See what jMeter recorded
Use the recorded sampler(s) to build your real test
Details here.

Aha, OK, than maybe you can link (bypass a web app) jMeter with Spring by using jMeter's jUnit Sampler to fire your jUnit test cases directly.
More here: http://jmeter.apache.org/usermanual/junitsampler_tutorial.pdf
Also, take a look here how a guy tried to write a custom jMeter Sampler that was supposed to mimic Spring's HttpInvoker (HttpInvokerProxyFactoryBean).

Related

Jmeter Math Confusion

I have A problem With The Jmeter Tool it dosen't view result i'm testing from my local host and i don't know where is the problem
This is my Recording templete
And This is my Local Host That I want To test It
I Don't Know What Is The wrong
You need to configure your browser to use JMeter as the proxy
If you're recording HTTPS traffic you need to import JMeter's certificate, see HTTPS recording and certificates chapter of HTTP(S) Test Script Recorder JMeter User Manual entry for more details
In case of any problems check jmeter.log file for any suspicious entries
Also be aware of an alternative way of recording a JMeter test: JMeter Chrome Extension, in this case you won't have to worry about proxies and certificates, just follow your test scenario steps in the browser and once done you will be able to export recorded requests in form of JMeter's .jmx test script

Jmeter HttpRequest shows "browser is currently set to block cookies"

I am new to Jmeter. I tried to send an HTTP request but the HTTP response showed "cookie is blocked"
enter image description here
I tried to create the HTTP Cookie Manager and set the cookie policy as Compatibility but doesn't work.
and also tried to set CookieManager.save.cookies=true in JMeter.properties file, but both don't work.
Any suggestions would be appreciated.
If this is a very first request - no cookies are involved, most probably the application you're testing tries to set a cookie via JavaScript and not using Set-Cookie header
As per Apache JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
So you need to inspect the page, you're opening using browser developer tools and if the cookies are being created/set by JavaScript - you will need to replicate the same logic using JSR223 Test Elements and Groovy language, check out Modifying Cookies in JMeter with Groovy article for more details.

SOAP request going to localhost

I'm testing a SOAP web service using Soap UI.
The WSDL location is on an external server, so I load and create a new project like this:
However, when I try to create a request, the endpoint points to localhost:
I have to manually insert the right endpoint URL for the request to work.
What could be behind this?
If you open the wsdl file in a browser or in a text editor, it will be clear that the endpoint has the same url, i.e., localhost, but not the actual one. That is the reason you are experiencing that.
This mostly happens also as developers try to use localhost while developing and it is not required/no point/does not make sense to have their hostname in wsdl unless it is a public wsdl. If QA team is using, then they will set their hostname in the endpoint, similarly for the other environments. So, you really do not have to worry about it, I believe.
In order to set the right endpoint at one place and apply for all requests( instead of changing it for each and every request), do the following:
Go to the service interface, right click and show interface viewer.
Click on Service Endpoints tab.
Click on + button.
Add the actual endpoint what you wanted
Click on Assign button, and select All requests and Test Requests from dropdown and say ok
Repeat the same if you have multiple interfaces in your project.
Save the project, and you are done.
You should be able to see the desired endpoint for all the existing test requests and even for the new one that you are going to create later.

querying Joomla! components from phpstorm does not work

I'm trying to test some Joomla!'s output from phpstorm by using the inner "test RESTful web services" as known as "Rest client".
Basically the URL I would like to test asks for the component to load and task to perform. The loaded model by the controller reads the body of the POST request for performing some task.
To test it, I set my "Rest client" up: POST option, URL and body content are properly filled and then I run my request. Unfortunately, Joomla! seems not to read my URL parameters and because of this the home page is returned instead of loading the component, view and running the requested task.
Here is a snapshot of my settings:
Has anybody bumped into this issue? Any suggestion?
I did it: I placed a new header item Content-Type to application/x-www-form-urlencoded and it worked smoothly.

How to use Intersystem's session within web services

I am trying to set some session information in one web method and return it in another web method, but the session data is always empty on the second web method. Here is what I tried
Web Method 1 - Sets session information
Method StartSession() As %String [WebMethod]
{
set %session.NewSession = 1
set %session.Data("key") = "dude"
Quit "Session Started"
}
Web Method 2 - Gets session information should return dude, but is returning blank
Method TestSession() As %String [WebMethod]
{
Quit $Get(%session.Data("key"))
}
To use sessions with Cache web services you need to set the SOAPSESSION class parameter of your web service class equal to 1.
Doing so will cause the web service to return a SOAP session header in the response. If you are using a client that was built to expect this header you may not need to set up anything else. Otherwise, your client application will have to read this header and include it in all further requests, so the server can know which session you are using. An example of this header given in the documentation is:
<csp:CSPCHD xmlns:csp="http://www.intersystems.com/SOAPheaders">value of
CPSCHD token</csp:CSPCHD>
Note that security is a separate issue that your example doesn't address.
Also note that Intersystems has decided that web services will continue to use a license for some period of time after the call has been made. I can't find documentation on this, and I believe it's something like a few seconds per call. I believe that this can cause license issues that would not occur if you used other software to provide web services, and had that other software call Cache via some mechanism other than web services. I believe this is true even when that other software carefully follows all the rules in the license agreement about named and anonymous users. However, I'm not certain about any of this licensing stuff. Still, you might want to do some testing before you commit to an architecture.
As an alternative to psr's answer another way to handle state is to use custom SOAP headers.
For example:
Create a class for your custom SOAP headers like below:
Class Headers.TimeStamp Extends %SOAP.Header
{
Property TimeSent As %TimeStamp;
}
In the web method do this:
set h=##class(Headers.TimeStamp).%New()
set h.TimeSent=$ZTIMESTAMP
do ..HeadersOut.SetAt(h,"Timestamp")
This will generate the following SOAP header:
<SOAP-ENV:Header>
<TimeStamp xmlns:hdr="http://www.myapp.org">
<TimeSent>60712,70996.027Z</TimeSent>
</TimeStamp>
</SOAP-ENV:Header>
This will allow state to be maintained within the SOAP headers rather than using Cache's session management.