cancel
Showing results for 
Search instead for 
Did you mean: 

How to change SoapUI Endpoint with different Port?

SOLVED
Highlighted
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
Highlighted
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

Highlighted
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
Highlighted
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

Highlighted
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

Highlighted
Community Hero

Re: How to change SoapUI Endpoint with different Port?

And where this script should be placed?


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Compete with community members in the TechCorner Challenge and get into the Leaderboard!

Rank Participant Points Earned
1 msiadak 12
2 nmrao 8
3 HimanshuTayal 3
Top Kudoed Authors