Web Services and QTP- Part 3: Adding Web Service Test Object
Apart
from Web
Services Testing Wizard we discussed in last part, let’s find out what are other possible
ways to work with Web services in QTP. What about adding Web services objects
directly into object repository and use the test object to add steps in test or
component.
QTP provides Web Service Add Object Wizard which
helps you to add the test object into the repository. These web service test
object behaves same as any other test objects while creating the steps in test
i.e. we can access all its operations in keyword view or in expert view.
To
open the Add object Wizard click the object repository at toolbar or select
Resources > Object Repository. Select Object > Web Service Add
Object Wizard. The
Web Service Add Object Wizard opens to show the Specify WSDL for Scanning
screen.
Specify the URL for your WSDL as you did at Web
Service Test Wizard and click Next. It will now show you the select
service screen. Here you can select the service and Port from the available
list. And click finish.
Close the Object Repository and the test object
is now ready to use in your test. To use a web service test object use
‘WebService(<Test Object>), and you can access any of the operations
available.
so as of now, we have seen that we add a test
object in the repository and can do further processing. Let’s now see how
can test a web service without adding the test object in the repository.
- WSDL
- Service and
- Port
Refer object repository for already added test
object
if we can define these in the script we will be
able to access the methods of web services.
WebService(“wsdl:=<your
wsdl>”,”service:=<your service>”,”port:=<your port>”)
So in order to invoke the method
CelsiusToFahrenheit from the WSDL used in earlier parts you can have the
statement in the script as –
Desc2 =
"service:=TempConvert"Desc3 = "port:=TempConvertSoap"' Call to the WebServiceFahrenheitval =
WebService(Desc1, Desc2, Desc3).CelsiusToFahrenheit("25")msgbox Fahrenheitval |
Which gives you the required output as 77.
All the other available operations can be carried
out with this approach.
No comments:
Post a Comment