2011-08-22 20 views
1

我在eviware板上問過這個問題,但還沒有收到答案。所以我會在這裏嘗試我的運氣。SoapUI:如何使用Groovy檢索表示數據

我有一個Rest服務,我正在測試,我想從代表選項卡中獲取信息,但我不知道如何和api不是最容易閱讀的。

這是我使用已經給我的錯誤是什麼:

import com.eviware.soapui.impl.rest.RestRepresentation 

x = RestRepresentation.getMediaType() 

log.info(x) 

這是錯誤:

No Signature of Method: static com.eviware.soapui.impl.rest.RestRepresentation.getMediaType() 
is applicable for argument types:() values: [] Possible solutions: getMediaType(), getMediaType(java.lang.String), getSchemaType(), getType() 

回答

0

由於@tim_yates已經解釋過,您需要一個RestRepresentation的實例。也許下面的代碼可以爲您指出正確的方向(即使線程是很老):

// First, fetch the proper REST Service (Interface) 
def service = testRunner.testCase.testSuite.project.getInterfaceByName('https://example.com:8090') 

// Then, dig down to the REST Representations 
service.operationList.each{ operation -> 
    operation.restMethodList.each{ method-> 
     method.representations.each{ representation-> 
      // Finally, do something with the instance 
      // of com.eviware.soapui.impl.rest.RestRepresentation 
      log.info representation.getMediaType() 
     } 
    } 
} 

我所採取的片段從我們在5.2.1了SoapUI Groovy的測試步驟之一。