jusbat
12 years agoOccasional Contributor
Web Service wsdl URL as variable
Hi all,
Hopefully someone will be able to help me. I have a TestComplete project in JScript and I am trying to control the wsdl URL of a web service I have included in my Project.
Basically, I have the same web service hosted on two different servers, I am looking for an easy way to change between the two servers without having to go in and manually change the URL over each time.
I was trying to create a script based on the information in this post - http://smartbear.com/forums/f75/t77029/how-to-change-the-webservice-wsdl-url-by-script
but I'm having no luck with it.
Here is an example of what I've tried:
I have added two web services to my project with the names in the format 'WS_[IP]'
I have two variables added to my Project Suite - 'ServiceIP' which is a persistent variable of type string, with a default value of 'WS_[IP]'; and 'Service' which is a temporary variable of type Object.
function WebServiceTest()
{
var testedServiceName;
testedServiceName = ProjectSuite.Variables.ServiceIP;
ProjectSuite.Variables.Service = eval(testedServiceName);
ProjectSuite.Variables.Service.SendMessage(XML.SendMessage);
XML.SendMessageResponse.Check(ProjectSuite.Variables.Service);
}
I'm getting a runtime error: 'ProjectSuite.Variables.Service is null or not an object' on the second last line.
Any help would be much appreciated!
Hopefully someone will be able to help me. I have a TestComplete project in JScript and I am trying to control the wsdl URL of a web service I have included in my Project.
Basically, I have the same web service hosted on two different servers, I am looking for an easy way to change between the two servers without having to go in and manually change the URL over each time.
I was trying to create a script based on the information in this post - http://smartbear.com/forums/f75/t77029/how-to-change-the-webservice-wsdl-url-by-script
but I'm having no luck with it.
Here is an example of what I've tried:
I have added two web services to my project with the names in the format 'WS_[IP]'
I have two variables added to my Project Suite - 'ServiceIP' which is a persistent variable of type string, with a default value of 'WS_[IP]'; and 'Service' which is a temporary variable of type Object.
function WebServiceTest()
{
var testedServiceName;
testedServiceName = ProjectSuite.Variables.ServiceIP;
ProjectSuite.Variables.Service = eval(testedServiceName);
ProjectSuite.Variables.Service.SendMessage(XML.SendMessage);
XML.SendMessageResponse.Check(ProjectSuite.Variables.Service);
}
I'm getting a runtime error: 'ProjectSuite.Variables.Service is null or not an object' on the second last line.
Any help would be much appreciated!
- Hi Justine,
I think that instead of:
ProjectSuite.Variables.Service = eval(testedServiceName);
you should try this:
ProjectSuite.Variables.Service = eval('WebServices.' + testedServiceName);
I.e. evaluated expression should be a string with the value like this (without quotes):
'WebServices.WS_[IP]'
Does this help?