Hello, and welcome back to this tutorial on Virtualize Free Edition.
Today we're going to be talking about creating a new virtual service. In this video, we're going to go over three topics. The first one is creating a new virtual asset. The second one is adding a responder to that asset. And the third one is starting the Parasoft Virtualize server. So, let's get started by starting Parasoft Virtualize.
So, we're just going to get it started here. It's going to take just a moment. I'm going to go ahead and pause the video while we're waiting for that to start up. Now that we have Virtualize started, we are going to set up our first virtual asset. Go to the menu here and find the virtual assets folder, and right-click on it.
When you right-click on it, you're going to Add New. Add Virtual Asset. I'm going to highlight the virtual assets folder here. We're going to give it a name. Once we give it a name, we're going to click Next. Now we're going to specify how to create the virtual service.
So you can see that for a REST, for example, we have a few different automated ways of generating the virtual service. We can use RAML definition or a Swagger definition. In the case of SOAP, we can consume WSDL or XML schema. We can even use recorder traffic to set up our virtual services. Since we are building this one from the ground up, we're going to go ahead and say Empty. Click Finish. Sets up the virtual asset.
So you can see here I now have my hello-world.pva over here on the left-hand menu. And if I expand it, you're going to see that I have an empty responder suite. The responder suite is a piece of our virtual service, which actually provides a response when a request comes in. Our virtual assets can have many different responders, and we can map a responder to a specific kind of request. For more on responders, watch our video on extending your virtual services. But for now, let's just add a single responder and configure it with a response message.
So to do that, we're going to right-click on my responder suite and click Add New Responder. And specifically, we're going to add a JSON message responder because that's the kind of response we want to send back. We're going to click JSON message responder and click Finish. And now you can see here I have an empty JSON response.
This I can configure for whatever purpose I wish. Now we can either paste in a literal JSON message here if we have a sample, or I can actually go to form JSON, and I can just go ahead and add the elements manually. So again, going to right-click, click Insert. So, to add that element, we're going to call this one Hello World. And the message type of response that we want is a string. So we're going to make sure that's set to string and click Okay. Now the contents of that element are going to be Hello World. Now that I have configured my element and its contents, I will go ahead and save this response.
So, we're going to go up here, and I click Save. Once that's saved, the only thing that I have left to do is go ahead and start up my virtual server so that the pva is actually hosted in a certain endpoint, and we can invoke it. We're going to go over here to the server. By default, when Virtualize is set up, it's going to use port 9080. In this case, however, I'm using Port 9080 for something else, so I've changed it to Port 9081. I've done that here in the Parasoft preferences. And I've gone down to Server, and I've changed that port to 9081 for the server. When it installs initially, it is going to be set for 9080. Like I said in this case, I had to set it to 9081 because I am consuming port 9080 with a different service. Now, once you have that set up, you're going to click on this green arrow here and click on the server here. You're going to click on this green arrow and you're going to see down here that the server's starting.
Once the server gets started, you can see here, everything is set up and ready and ready to go. Now, once the server has started, my hello-world.pva will be hosted at a URL which is equal to its name. What I mean by this is it will be hosted at local host port 9081/Hello-World. So now that it's up and running, let's just go over to my browser, which I've already put in that URL. And so now you can see we're getting the JSON message response of "hello-world" at local-host:-9081/HelloWorld.
So now you can see how easy it is to create your virtual assets, create a response and start the Parasoft Virtualize server. That server will always respond now in the same way as you set it to do. Up next, we're going to talk about extending a virtual service.