2012-12-06 56 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}

相关问题