cancel
Showing results for 
Search instead for 
Did you mean: 

How to Add HTTP Headers to test request using API

Regular Contributor

How to Add HTTP Headers to test request using API

Hi,
I do have more than 100 WsdlTestStep (SOAP request) in my testsuite and I would like to add custom HTTP headers to each request.

I do not want to add manually, as mentioned here :http://www.soapui.org/SOAP-and-WSDL/adding-headers-and-attachments.html

I had a look at this : http://www.eviware.com/forum/viewtopic. ... 46&start=0 but its only for RESTful services..

I also see a method public void setHttpHeaders(StringToStringsMap httpHeaders) in class AMFRequestTestStep ... Is there any such method for wsdlteststep ?

I got wsdlteststeprequest.modelITem.getConfig() returning me

<con:settings/>
<con:config xsi:type="con:RequestStep" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<con:interface>Exp_IProductVersionService_SOAP_IProductVersionServiceHttpBinding</con:interface>
<con:operation>createProductVersion</con:operation>
<con:request name="ReAEn_TC.019 ProductVersionService createProductVersion TestStep">
<con:settings>
<con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;[color=#0000FF]entry key="Authorization" value="Basic VEVTVF9JJkFfU3VwZXJVc2VyOmZhYnJpYzEwMQ=="[/color] xmlns="http://eviware.com/soapui/config"/></con:setting>
</con:settings>


How to set value for "entrykey" and "Value" here ?
4 REPLIES 4
Regular Contributor

Re: How to Add HTTP Headers to test request using API

Hi, I managed to find a solution from other posts in this forum, however am strucked again..

import com.eviware.soapui.impl.wsdl.teststeps.*
import com.eviware.soapui.support.types.StringToStringMap ;

def tc = testRunner.testCase.testSuite.getTestCaseByName("TESTCASE_NAME")
def ts = tc.getTestStepByName("TESTSTEP_NAME")

def headers = new StringToStringMap()

headers.putIfMissing("Authorization","Basic TVF9JJkFfU3VwZXJVc2VyOmZhYnJpYzEwMQ==")
log.info ts2.getHttpRequest().setRequestHeaders(headers)


I'm using SOAPUI 3.6.2 Pro version.. am getting error message as follows


groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequest.setRequestHeaders() is applicable for argument types: (com.eviware.soapui.support.types.StringToStringMap) values: [[Authorization:Basic VEVTVF9JJkFfU3VwZXJVc2VyOmZhYnJpYzEwMQ==]] Possible solutions: setRequestHeaders(com.eviware.soapui.support.types.StringToStringsMap), getRequestHeaders()

Re: How to Add HTTP Headers to test request using API

Hi,

Please check viewtopic.php?f=4&t=5326

regards,
Dragica
/www.eviware.com


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.
Contributor

Re: How to Add HTTP Headers to test request using API

Suggested link from Dragica is not working any more. Is this topic still available in the current SMARTBEAR COMMUNITY?

Community Hero

Re: How to Add HTTP Headers to test request using API

You can leverage Events RequestFilter add the required headers before sending request.


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors