Showing results for 
Search instead for 
Did you mean: 

Add http Headers at Step - Java

Occasional Contributor

Add http Headers at Step - Java

We are trying to Automate our Suite from a Java based application. We have referred SOAPUI 5.2.1 libs in our project.
So far, I am able to control execution of Suite from my app.
We are facing challenges while Adding Headers (authorization headers) to the requests (at WsdlTestStep level).
We searched on google, but could not find a way to add http headers.

Following code sample matches with our requirement, but could not find equivalent APIs for Java. (believe its in groovy, we need Java)


Our code:
WsdlTestStep testStep = objectcase.addTestStep("httprequest","Valid","my REST url","GET");
testStep.setPropertyValue("Authorization", "Bearer xxx"); // tried this, didn't work

TestCaseRunner testCaseRunner = new WsdlTestCaseRunner((WsdlTestCase)objectcase, null);
TestCaseRunContext testStepContext = new WsdlTestRunContext(testStep);
testCaseRunner.getTestCase().getTestStepAt(0).setPropertyValue("Authorization", "Bearer xxx");, testStepContext);

Referring to
It says we should get testRequest object from step, but I could not find any method with 'Request' label.

Could you please help me to understand how to retrieve httpRequest from Step using Java. Or alternate approach to set http headers.




Tags (2)
Occasional Contributor

Re: Add http Headers at Step - Java

I am able to add headers, sharing if required by anyone .


StringToStringMap headers = new StringToStringMap();
headers.put("Authorization", "Basic xxx");
HttpTestRequestStep testStep = (HttpTestRequestStep)objectcase.addTestStep("httprequest","Valid","token url","POST");
TestCaseRunner testCaseRunner = new WsdlTestCaseRunner((WsdlTestCase)objectcase, null);
testStepContext = new WsdlTestRunContext(testStep);

//, testStepContext);


System.out.println("JSON Response from server"+testStepContext.expand("${#Response}"));

New Here?
Join us and watch the welcome video:
Building with the Collaborator API

Help Documenation
The Collaborator API is a JSON-RPC API that lets you integrate with Collaborator 9.0 and above. For more information about how the API works, check out the API description here:

Sample Plugins
For an example of an add-in that uses the API, take a look at the Microsoft Word Add-in for Collaborator:

We list all the great plugins our network has already built on this page on the SmartBear website.