We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More

Forum Discussion

jusbat's avatar
jusbat
Occasional Contributor
13 years ago
Solved

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!

 

  • 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?

5 Replies

  • AlexKaras's avatar
    AlexKaras
    Community Hero
    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?

  • jusbat's avatar
    jusbat
    Occasional Contributor
    Yes! Thank you!!! Much appreciated :)
  • AlexKaras's avatar
    AlexKaras
    Community Hero
    Cool.

    Great to know that the recipe works not only for me :)
  • ChrisPro's avatar
    ChrisPro
    Frequent Contributor
    URL is configured by user in an INI file.

    So, ti is not possible to know the value before the parsing.



    A solution?
  • Hi Chris,



    TestComplete doesn't support parameterizing WSDL URLs and service endpoints.



    But our web service testing tool http://www.soapui.org supports it:

    http://www.soapui.org/Functional-Testing/working-with-properties.html#4-example-n-centralized-endpoint

    http://forum.soapui.org/viewtopic.php?f=2&t=8091#p23559



    May I recommend using SoapUI instead? It has a free version.