Is it possible to make a soap web service call in VB script from uft tool - web-services

I am new to web service.
I am trying to send a request and get response from a SOAP webservice from my uft code(VB script). How can I do this. When I try to find a solution, I m being shown how to test webservice. But here I am not testing webservice, it is a part of my flow.

Unified Functional Testing (UFT) = API Testing (formerly Service Test - ST) + GUI Testing (formerly QuickTest Professional - QTP)
From the API testing part of UFT, you can perform the web service call. Then, once you have the API testing call ready (i.e.: SOAP, REST..) you can call the API testing action from a GUI Testing script (VBScript) using the RunAPITest statement.
For more information, check the below topic from the help files (F1):
Tutorials > UFT Tutorial > Part 4: Create and run GUI and API tests in a single test > Lesson 2: Call the API test from a GUI test

Here is the vb script to call the soap service and get the response.
Dim oXMLHTTP,result
'Request XML
strEnvelope="C:\request.xml"
url = "soap end point"
Set oXMLHTTP=CreateObject("MSXML2.XMLHTTP.4.0")
oXMLHTTP.Open "Post", url, false
oXMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHTTP.setRequestHeader "Content-Type", "application/xml"
oXMLHTTP.send (strEnvelope)
result = oXMLHTTP.responseText
Set oXMLHTTP=Nothing

There are two ways to do what you want.
1) From the code itself, you can test the service in UFT.this might help http://relevantcodes.com/working-with-webservices/
2) You can use the UFT APi testing. There you can split the UFT GUI and API Test and run one after another in a flow.

Related

SoapUI: Create mock service with pass-through behavior for selected methods

While developing a web application I have the following use case:
a 3rd party Web Service with quite a lot of methods is deployed on a test server A (with a single endpoint, e.g. http://3rdPartyServer/3rdPartySvc?WSDL)
a new method is about to be implemented in the near future, but I need to use it now
the rest of the methods are used throughout my code extensively
So I would like to do the following:
Create a mock service in SoapUI locally, based on the new WSDL which includes the new WS method (i.e. a superset of the WS methods currently on server A)
point my local application server to use the SoapUI mock service endpoint
mock only the response of the new WS method (create a dummy response for it in SoapUI)
let the other WS method calls to reach server A and return whatever it returns normally (i.e. use SoapUI as a proxy for these calls)
I've gone through the SoapUI documentation regarding service mocking and have used it numerous times, but could not find an option for such "pass-through" behavior.
When you read in your WSDL, the endpoint will point to your server.
Open your service, and select the service endpoint.
Add a second endpoint, to point to your mock. SoapUI has little bit of documentation showing this here. Only step "2. Getting Started" applies, not step 3!
In each of your tests, where you are using the mocked method, you will need to select the mock endpoint. Further discussion is here.

How to test multiple Web Services with one script using UFT?

I am trying to create a set of Regression Test scripts to test the different Web Services and the corresponding methods related to my Web Application in HP UFT. I am using the API testing feature of UFT. I have the request and response XMLs (obtained manually) of each web service method necessary for the testing. There are more than 50 web service methods to be tested. The test cases for all of them are same. The input data of the request is currently being set by parameterizing the data from an excel spreadsheet.
Since the test cases are exactly same and the input data for all the web service methods have similar fields, such as First Name, Last Name, LoginID etc., I want to know if there is a way to write a single script which dynamically reads the web service method name and the associated data from the spreadsheet and uses it in the request XML file (same name as the web service method) which is also loaded in run time.
In this way, after the script has been developed, all I need to do prepare a list of all the web service methods to be tested and enter them in the Test spreadsheet along with the required request data. The script would loop through all the web service methods and execute the test cases for each web service method one by one.
in your case I think you should use a Soap Request method rather than a Web Service Call. Using soap request, other than the message itself, you can parameterize also the Endpoint Address and the SoapAction
Hope this helps
Yossi

how to write unit tests for REST web services developed using apache-cxf with spring without using Maven

I have developed a REST web application using apache cxf library. I am able to access them using a browser and test. I want to write unit tests for the services.
I tried testing it using embedded Jetty server with cxf.
After starting the Jetty server, I am getting a proxy using WebClient API of cxf. The relevant code is
WebClient client = WebClient.create(ENDPOINT_ADDRESS);
client.accept("text/xml");
client.path("/studyservice/topimstudydetails");
client.replaceQuery("pnlId=3&lclId=30&indId=442&maxImStudies=99&rName=DEV");
TopIMStudyDetailsResponse resp = client.get(TopIMStudyDetailsResponse.class);
assertEquals(resp.getStatus().getReturnCode(),0);
The call to the service is successful as I can see the logs, but I'm get a null pointer where the service is trying to make a dao call. The dao is declared as a dependency for the service. How can we get a proxy with all the dependencies injected ?
May be you'll find the following posts helpful:
http://tarlogonjava.blogspot.co.il/2011/12/running-integration-test-using-with.html
http://tarlogonjava.blogspot.co.il/2011/12/running-integration-tests-using-with.html
The second post is about replacing the data source with a special in-memory data source for tests.

Automated testing of a SOAP Service

Before just answering: Use SoapUI. Please read the Question, because I tried SoapUI.
I have a lot big wsdl Files. Every Method works like this:
First do a synchronous Call:
Request: Please do foo and send Request to URI: XY
Response: Ok, your Job has UUID: abc
After the Job is done, my Sevice will respond to URI: XY, by sending only a request Message synchronously:
Request: Ok I finished your Job with the UUID: abc and the result is bar
We needed to use this behavior, because we have a pool where all answers will be stored and are identified by UUID.
Do you know a possibility to test such a SOAP Service?
I tried:
SOAP UI
BPEL Unit (I think it should be possible with BPEL Unit but I can't make it work properly)
Please don't recommend writing my own JAVA tests, because I have more than 100 methods to test.
Also the Tests need to be run and the results need to be analyzed automatically in a Test-suite, I can't do this for 100 Methods by hand everytime I change the code of the Web Service.
I'm one of the SoapUI Guys, so you'll probably HATE my answer...
But the solution is using SoapUI; more specifically using MockResponse TestSteps. SoapUI is NOT very strong when it comes to BPEL testing, but using MockResponse Steps you can fix it.
Look here: http://www.soapui.org/SOAP-and-WSDL/testing-asynchronous-services.html. Even though all calls are done synchronously, this can still be considered asynch testing since we have more than plain request/response.
I also know that Oracle has got a great write up on this.
What you need to do is to create a mock service that will receive the second call which signals that the job processing is done. This is can be done in SOAP UI, you can read about how to create a mock web-service here.
You can test Web Services by using Eclipse.
Just put the WSDL file on your project -> right click on the file -> web services -> test using web service explorer.
You will have an interface showing all your WSDL operations and fields which are needed.

SoapUI mocking asynchronous services

We use SoapUI to mock web services to test our application (APP) before we have access to real webservices.
Creating a synchronous Mock Service which will return predefined response is straightforward. However I have to mock some asynchronous services where the APP sends a request, the SoapUI immediately responds back with confirmation (e.g. SUCCESS) and then after a predefined interval the SoapUI will call our application back (the APP is then acting as a server). I managed to do it using test case where first step is MockResponse, then delay and then MockRequest (to call our app).
The above works fine but I'd like to do it by scripting it directly in the Mock Reponse to avoid using Test Cases. I managed to write the script which when a Mock Service receives request it will fire the callback.
def project = result.mockOperation.mockService.project
// The API documentation doesn't say what finish is supposed to do but I try (doesn't help)
result.finish()
// Request that will be returned back - THE CALLBACK
def request = project.interfaces["LocationServicesOperation"].operations["ackLocation"].getRequestByName("Request 1")
sleep(4000)
request.submit(new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( ), false)
The issue with the above is that it will fire the callback BEFORE sending the response for the initial request. I tried using event handling in SoapUI PRO but I can't get that working. In Wireshark I can see the communication like this:
1) APP request -> SoapUI
2) SoapUI callback -> APP
3) APP confirms 2) -> SoapUI
4) SoapUI confirms 1) -> APP
However it needs to be:
1) APP request -> SoapUI
2) SoapUI confirms 1) -> APP
3) SoapUI callback -> APP
4) APP confirms 2) -> SoapUI
The code above is actually from MockRunListener.onMockResult event in SoapUI Pro. the result.finish() doesn't do the trick.
Thanks for any tips!
I finally found a solution at http://www.eviware.com/forum/viewtopic.php?f=5&t=3542&p=12474&hilit=asynchronous#p12474
The trick was instead of dispatching the request directly from within the response script to add the callback request to a test and then call the test. This will cause the mock runner to first send response to the request and after that run the test case.
The advantage is that the test case is triggered dynamically and doesn't need to run all the time.