謝謝@Nick Grealy,我有它的工作。一些注意事項:
- 從內聯XML「expectedRequest」省略XML聲明或者你得到一個異常「的處理指令目標匹配‘[XX] [MM] [11]’是不允許的。」
- 您需要定義2響應模擬消息:
- FailureResponse
- SuccessResponse
這裏是SOAP UI v 5.2.1,模擬調度腳本中的Groovy代碼
import org.custommonkey.xmlunit.*
XMLUnit.setIgnoreWhitespace(true)
XMLUnit.setIgnoreComments(true)
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true)
XMLUnit.setNormalizeWhitespace(true)
def expectedRequest = '''
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>
</soap:Envelope>
'''
def actualRequestReceived = mockRequest.requestContent
def diff = new Diff(actualRequestReceived, expectedRequest)
diff.compare()
log.info('actualRequestReceived:' + actualRequestReceived)
log.info('expectedRequest:' + expectedRequest)
log.info('identical:' + diff.identical())
log.info('similar:' + diff.similar())
if (!diff.identical) {
responseToUse = "FailureResponse"
} else {
responseToUse = "SuccessResponse"
}
return responseToUse
Hi @MattG,你可以請你提供一個樣本,顯示你已經發現了什麼d? –