Groovy Script to send response value to username in Outgoing WS Security Configurations
Hi,
I need help with sending response value to username in Outgoing WS-Security Configurtions, see attached SOAP UI Screenshot for more clarification.
I want to send the highlighted value in response to WS-Security Username field
Hi pankajmalinda ,
Written below code hope it will help you to set desired values :
def project = testRunner.testCase.testSuite.project; def WssC = project.getWssContainer(); def outgoingWSSName = "APPService" def userName = "testUserName"; def password= "testPassword"; def passwordType = "PasswordText" def entityName = "Username" def outgoingObj; def list = WssC.getOutgoingWssList() if(list.size() == 0){ outgoingObj = WssC.addOutgoingWss(outgoingWSSName); addEntry(outgoingObj , entityName, userName, password, passwordType); } list.each{ if(it.name.toString() != outgoingWSSName){ log.info "test" outgoingObj = WssC.addOutgoingWss(outgoingWSSName); addEntry(outgoingObj , entityName, userName, password, passwordType); } else{ log.info "tesT" test1 = WssC.removeOutgoingWssAt(0); outgoingObj = WssC.addOutgoingWss(outgoingWSSName); outgoingObj = WssC.getOutgoingWssByName(outgoingWSSName); addEntry(outgoingObj, entityName, userName, password, passwordType); } } def addEntry(outgoingConfObj, entryName, userName, password, passwordType){ def signature = outgoingConfObj.getEntries() def signatureAdd = outgoingConfObj.addEntry(entryName) signatureAdd.setPassword(password); signatureAdd.setUsername(userName); signatureAdd.setPasswordType(passwordType) }
It is adding new Outgoing Wss Configuration 'APPservice', I am trying to set the Username field in existing Outgoing Wss Configuration 'APPservice' from response value of a test step as mentioned in the original query.
I tried to remove the addOutgoingWss and replace it with getOutgoingWss in if-else condition but it didn't work out well.
Hi pankajmalinda ,
Try to remove both Outgoing WS Security and then run the code. Hope it will work fine.