raiqee
6 years agoOccasional Contributor
How to change SoapUI Endpoint with different Port?
Given I have one Endpoint but multiple Ports, how can I set it in SoapUI like Custom Property
e.g htts://10.1.10.101:{port}/
- Please check the documentation below regarding custom properties
https://www.soapui.org/scripting-properties/property-expansion.html Hi Raiqee,
You can use following code to set the port:-
testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Port", "80") def port = testRunner.testCase.testSteps["Properties"].getPropertyValue("Port"); def endPointUrl = testRunner.testCase.getTestStepByName("REST Service Name").getHttpRequest().getEndpoint(); String endpointPort = endPointUrl+":"+port log.info endpointPort
If you have multiple ports use for loop to set it.
testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Port", "80") testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Port1", "81") testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Port2", "82") testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Port3", "83") def data = context.testCase.getTestStepByName("Properties"); String[] prop = new String[data.getPropertyCount()]; prop = data.getPropertyNames(); for ( int i = 0 ; i < prop.size(); i++ ){ def port = testRunner.testCase.testSteps["Properties"].getPropertyValue(prop[i]); def endPointUrl = testRunner.testCase.getTestStepByName("REST Service Name").getHttpRequest().getEndpoint(); String endpointPort = endPointUrl+":"+port log.info endpointPort }
Hope, this solution helps you out.