cancel
Showing results for 
Search instead for 
Did you mean: 

How to change SoapUI Endpoint with different Port?

SOLVED
Occasional 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}/

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Hero

Re: How to change SoapUI Endpoint with different Port?

Please check the documentation below regarding custom properties

https://www.soapui.org/scripting-properties/property-expansion.html


Regards,
Rao.

View solution in original post

Super Contributor

Re: How to change SoapUI Endpoint with different Port?

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.

View solution in original post

3 REPLIES 3
Community Hero

Re: How to change SoapUI Endpoint with different Port?

Please check the documentation below regarding custom properties

https://www.soapui.org/scripting-properties/property-expansion.html


Regards,
Rao.

View solution in original post

Super Contributor

Re: How to change SoapUI Endpoint with different Port?

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.

View solution in original post

Community Hero

Re: How to change SoapUI Endpoint with different Port?

And where this script should be placed?


Regards,
Rao.