2012-12-06 54 views
2

我收到一個15位數的用戶ID,並想修剪它的最後3位數然後發送回請求發件人。索取樣品低於:從請求傳輸值到響應(soapUI模擬服務)

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> 
    <env:Header/> 
    <env:Body> 
     <lookupSubscriberInfo xmlns="http://testID.com/V1_0"> 
     <callingParty>testParty</callingParty> 
     <subscriberRequestList> 
      <testId>888905425616681</opaqueId> 
     </subscriberRequestList> 
     </lookupSubscriberInfo> 
    </env:Body> 
</env:Envelope> 

我已閱讀本 http://www.soapui.org/Service-Mocking/creating-dynamic-mockservices.html 但無法弄清楚..

回答

1

我無法通過XPATH,另一方面得益於XmlSlurper做它一直..

import groovy.util.XmlSlurper 
def parsedContent = new XmlSlurper().parseText(mockRequest.requestContent) 
context.MSISDN = parsedContent.Body.lookupSubscriberInfo.subscriberRequestList.opaqueId.toString().substring(3,15) 

爲了使用MSISDN值您應該使用以下內容

$ {MSISDN}

相關問題