2012-06-13 25 views
0

我有一個Web服務,我生成一個示例請求,然後取代所有的?最簡單的情況是0。它工作正常。然後我更換這樣的一個值:soapui 2.0.2給我NumberFormatException甚至最簡單的表達式

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://interfaces.mypackage.foo.com"> 
     <soapenv:Header/> 
     <soapenv:Body> 
      <int:getCheckResults> 
      <criteria> 
       <startTm> 
       <time>${=0}</time> 
       </startTm> 
      </criteria> 
      </int:getCheckResults> 
     </soapenv:Body> 
    </soapenv:Envelope>  

(我想是這樣的,最終,我想通過讀取日期這樣當接口需要一個很長毫秒值的原因):

<startTm> 
     <time>${= new java.util.SimpleDateFormat("MM/dd/yyyy hh:mm z").parse("01/01/2012 04:00 GMT"}</time> 
    </startTm> 

它總是給我同樣的答案,而不是調用服務 - 這曾經工作,但我不知道現在有什麼不同,也許它在舊版本的SoapUI中工作?

<soapenv:Fault> 
     <faultcode>soapenv:Server.generalException</faultcode> 
     <faultstring>java.lang.NumberFormatException: For input string: "" Message being parsed:</faultstring> 
    </soapenv:Fault> 

幫助!!

回答

0

我建議你使用上下文變量和Groovy腳本。

在這個SOAP請求之前運行,加上這樣的事情(我沒把你的代碼,但我想你明白我的意思),Groovy腳本:在

import java.text.SimpleDateFormat 
Date today 
String formattedDate 
SimpleDateFormat formatter 
Locale currentLocale 
currentLocale = new Locale("en", "US") 
formatter = new SimpleDateFormat("yyyy-MM-dd", currentLocale) 
today = new Date() 
formattedDate = formatter.format(today) 
log.info(formattedDate) 
context.setProperty("formattedDate", formattedDate) 

然後SOAP請求把這個:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://interfaces.mypackage.foo.com"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <int:getCheckResults> 
     <criteria> 
      <startTm> 
      <time>${formattedDate}</time> 
      </startTm> 
     </criteria> 
     </int:getCheckResults> 
    </soapenv:Body> 
</soapenv:Envelope>  
+0

謝謝 - 我明白你的意思,但是因爲我試圖從SOAP UI運行它,所以我沒有任何地方可以事先運行這個goovy腳本。這個問題似乎是在SOAPUI本身,它擴展$ {=一些java表達式}(或不)。我將吹走2.0.2並嘗試最新的4.5(win7 64bit)並看看如何去... –

+0

有一個Groovy測試步驟,您可以添加到您的肥皂UI測試中。也許你沒有看到它,因爲你還沒有創建TestSuite> TestCase等。如果你直接從「I」圖標下的生成步驟運行,那麼你不能添加Groovy測試步驟。 – chrismead

0

好了,我就吹去SOAPUI版本2.0.2,並安裝了最新的4.5.0,現在它照常工作。上帝知道什麼是錯的。

希望這可以幫助別人。

+0

有趣。我不知道你可以這樣做。 – chrismead

相關問題