hi all
i coded a custom web service for sharepoint in a remote machine and will deploy it later to the host machine
but how programs do i need to install to my computer to test that web service
Use a tool such as
Storm
SoapUI
Web Service Studio
(All open source)
You'll probably need a test application to sit on the same system as the web service.
It will locally fire the webservice and some of the test fixtures will only monitor what it returns.
The rest of the fixtures should examine what the webservice actually interacts with on the server side.
ie: If you have a webservice that accepts a command then starts a Workflow, you would:
a) Ensure that the correct response is given by the webservice when invalid input is given
b) Ensure on the server side that the correct workflow is instigated and started with the correct initialisation data.
You would probably need many, many test cases depending on what your webservice actually does.
Related
I already know how to write JUnit test cases (can also use Mockito). Thanks for the simple tutorials in the web for that. The only problem is that I can't find any examples on implementing it to an actual or let's say realistic project.
I have a simple REST web service which uses Servlets. It has an API method that sends a POST request to another web service then arranges the data as its response.
The API request is processed by two layers:
Servlet (Controller) - validates the request parameters
Service - The sender of the POST request to another web service
Here's what the service method does:
Prepares a parameter data (some attributes are provided in the paramaters of this request, some are retrieved from the database)
sends a request to another web service which responds with an image url for a QR Code
Decodes the QRCode image and then responds to its request with the decoded text
What are the unit tests cases needed for this?
How about integration tests? Do I have to use ServletUnit, or can I just run the server and write tests with requests to the running server?
Unit testing usually involves testing a single class in isolation. So you would need tests for the servlet class and for your service class as well.
If you're interested in unit testing a servlet, then have a look at these answers. In your case, you need to mock any external dependencies and check for example if valid parameters are sent to the service method.
Unit testing the service method includes mocking all external dependencies (web service, database) and only test the logic that's performed in the method (e.g. data is prepared correctly, QR decoding and responding with the correct text).
Most of the time you end up writing integration tests since you have multiple components which need to work together. There are multiple possible solutions to tackle that problem. You could create a separate integration testing environment which tries to replicate your production environment as closely as possible (web server, application server, database). For smaller projects that might be too much work and you could just spin up an embedded Tomcat with some kind of an in memory database (H2 for example). Keep in mind that for integration tests to be repeatable you might have to reinitialize the database for every test run.
In addition, you mentioned a web service which responds with a URL to a QR code. If you're not in control of that service, I would try to mock that service as well. You don't want to have a failing integration test because of a web service which might not be available 100% of the time.
Since your Servlet acts as a RESTful web service, take a look at rest-assured. This is a DSL for testing REST services.
We're in the process of setting up a web service and clients using Swagger to define the interface. Our client is a c++ app, and we're using the C++/Qt5 code generator provided by Swagger to create our interface classes.
I'd like to create a unit test framework that will let us test these interface classes, but to do so, I'd like to have a local app that is running the server end of the protocol such that we can connect as locally.
I tried running the "Generate Server" feature on the swagger editor (http://editor.swagger.io/#/) to produce different servers, but the only one I could get to work was the node.js one, which doesn't appear to be a server that fulfills the defined protocol, but instead a documentation server that allows you to use web forms to send messages to another server.
I don't need anything fancy - just a local process I can send HTTP to that will send back canned responses in order to close the connectivity loop. I know little-to-nothing about web application development, and the team that is responsible for implementing our actual server has bigger fish to fry right now than to write a testing app for me.
I am familiar with SOAP web services, and have done some PUT/GET/POST verbs in REST web services. Somewhere I read that your REST web service can return a code if something goes wrong at the web service, but can it return twice?
By that I mean: supposed your REST web service is querying a database and it is doing a lazy load, so it is taking a while. You intend to return an array of values from the database back to the client that called the REST web service. But while the REST web service is working on your database query, can it return a string that says "Query is 10% complete, please wait" or something like that? Can the REST web service call another web service that somehow communicates back to the client this information?
I doubt this is possible, otherwise I would have seen it, but I ask anyway.
Target platform is Visual Studio 2010 Professional with C# and MS Sql Server 2008
You could look at COMET, which according to wikipedia:
...is a programming technique that enables web servers to send data to the client without having any need for the client to request it. It allows creation of event-driven web applications which are hosted in the browser.
There are a number of articles on the web about doing this plus a couple of frameworks on sourceforge and github. However this is not trivial. I know it is possible with REST because a previous employer of mine has several real-time feeds based on RESTfull endpoints using COMET for push.
See here:
http://www.aaronlerch.com/blog/2007/07/08/creating-comet-applications-with-aspnet/
http://sourceforge.net/projects/emergetk/
https://github.com/Oyatel/CometD.NET
Suppose I have 2 web services A and B in SOA project. Both web services are running on a remote servers. Web Service A depends on information available from only a locally installed desktop application on a human actor machine and thats all web service A does i.e. provide this information). There are hundreds of such human actors with the same locally installed application providing its own information that web service A needs. Web service B needs this information from web service A, the result of which (which is the whole benefit of this project) is provided to that human actor who originated this process (by loging into system and clicking some command button). So this human actor is acting like the consumer of Web service B. The question is how can I make this locally installed application act as Web Service A (in the context of SOA project)?
This question could best be answered by some one with extensive experience in Web services and SOA.
This SOA project uses java, like ESB based on Java and there is no Microsoft specific services running although the desktop application is a Windows application. The application provides c/C++ API for an external process to call and retrieve the information needed by Web service A. What I want is the both web services A and B are hosted on remote server and interacting with each other via ESB but the problem is how to make local application information available to Web Service A?
There are two types of solutions
The first: have the original client application add a parameter with the address of web service A, and use this address for calling the service.
The second: pass a more abstract user identifier from the client (actually, there's a good chance you have such a field in the service). and use a translation service to retrieve the physical address corresponding to this id.
To allow such translation, the desktop application that acts as a server needs to "register" with the translation service when starting up.
If you are using an ESB, or other SOA infrastructure (like a service directory, message queuing service) it will include much of the functionality you need to build the translation service.
regarding the actual hosting of the service in the client machine.
the simplest solution is to use a different process from the actual application, and just access the files or DB the application uses.
In this case you can use any infrastructure you like to develop the service.
a more complex scenario is when you need the actual application to supply the service. in this case you will need to have a thread in the application that listens to service requests.
if you are using WCF see Hosting Services about how to host a web service in your application.
EDIT
some additions regarding you clarification.
as I understand, the desktop application exposes a C\C++ API that is available for external processes on the same machine.
You can either write a web service that will use this API. Googling "C++ Web Services Windows" will give yo several relevant pointers on implementing those.
Another good option is to use a messaging infrastructure. most JMS providers provide API's in languages other then Java - including C++.
Your application will be a C++ windows service that listens and sends messages to you JMS provider.
I want to expose a web service on one node that defers onto the same web service contract on another node, basically then, proxy the web service, both nodes running glassfish.
I am using netbeans and jax-ws and I cannot get it to work. I generate the web service server part and the web service client part and use the same dto's. So the service method is very simple, just passes the request on.
My current problem is that it is insiting on using ws-coordination to "coordinate" and this uses ssl to connect between the servers and I haven't configured this so it fails.
using Glassfish 2.1 and netbeans 6.7
Has anyone successfully done this? Does anyone know how to disable ws-coordination? I'd rather not use ws-coordination as I definitely don't need it and don't want to have to configure ssl.
I've done something similar using (AsyncProvider)-based Web services.
However, you might need to write your own TubelineAssembler to create a tubeline without the Tube that processes the ws-coordination related elements. An example of how to create your own TubelineAssembler can be found here.