Using the below code snippet or Groovy Script we can add headers to all the request in a test case.

 import com.eviware.soapui.support.types.StringToStringMap 
 def headers = new StringToStringMap()
 headers.put("name","value");
 headers.put("name1","value1")
 headers.put("name2","value2")
 testRunner.testCase.testSteps.each
 {
  q->
  if(q.getValue().config.type.equals("restrequest") || q.getValue().config.type.equals("request"))
  {
   q.getValue().getHttpRequest().setRequestHeaders(headers)
  }
 }
 
For more details on how to add/update header using Groovy Script, please refer this article. Groovy script to update the header value in all steps in a test suite.

 import com.eviware.soapui.impl.wsdl.teststeps.*
 import com.eviware.soapui.support.types.StringToStringsMap

 for( testCase in testSuite.getTestCaseList() ) {
    for( testStep in testCase.getTestStepList() ) {
    if( testStep instanceof WsdlTestRequestStep ) {
    def headers = new StringToStringsMap()
    headers.put(testSuite.getPropertyValue("ExampleHeaderName"),testSuite.getPropertyValue("ExampleHeaderValue"))

    log.info("Setting HTTP headers ${headers} in test case ${testCase.getLabel()}")
    testStep.getTestRequest().setRequestHeaders(headers)
    }
    }
 
Just set the properties ExampleHeaderName and ExampleHeaderValue for your TestSuite and use the script as "Setup Script" of the TestSuite.

Reference : 
      http://www.soapui.org/forum/viewtopic.php?t=3746
      https://thewonggei.wordpress.com/2010/08/05/configure-http-basic-auth-once-for-soapui-test-suties/
Reactions:
 
Top