Categories
Uncategorized

Testing Your ScriptLink API with Postman

Last week, we setup our SOAP testing using SoapUI. This provides us a way to see how our API responds to various OptionObject2015 configurations. There is another tool that can be used called Postman. Depending on your context you may prefer this tool over SoapUI. This week, we will walk through the same process using Postman instead.

Last week, we setup our SOAP testing using SoapUI. This provides us a way to see how our API responds to various OptionObject2015 configurations. There is another tool that can be used called Postman. Depending on your context you may prefer this tool over SoapUI. This week, we will walk through the same process using Postman instead.

When we left off, we had created our first Hello World ScriptLink API in .NET using C# and Visual Basic. If we created them correctly, the we should be able to call the RunScript method with the HelloWorld parameter and receive an Error Code 3 with the ErrorMsg “Hello, World!” Let’s test that.

What You Will Need

To complete this walkthrough, you will need the following:

  1. Visual Studio Community 2019.
  2. The Hello World solution we set up previously.
    I will be using the C# solution for my examples, but the process is the same for the Visual Basic solution.
  3. Postman.

Visual Studio Community 2019 and Postman are free to download and use. Paid versions will add additional features that we will not use in this walkthrough.

If you don’t have your Hello World API setup yet, go back to my previous article to set it up.

Start Your Web Application

Our first step is to open our solution in Visual Studio and run it.

  1. Launch Visual Studio 2019.
  2. Open our ScriptLink demo solution. For me, it is RS.ScriptLinkDemo.
  3. Press F5 to begin debugging the solution.
  4. You may receive a security alert like this. This means that the browser does not trust the SSL certificate provided by Visual Studio. Go ahead and proceed.
Screenshot of Visual Studio Self-Signed SSL Certificate Warning
Untrusted Visual Studio SSL Certificate Shown in Mozilla Firefox 70
  1. If you see the default homepage of our web application like this, then you will need to enter the path to the ScriptLinkController.
Screenshot of HTTP Error 403.14 Forbidden at Web Application Homepage
Web Application Homepage Forbidden
  1. Once you are at your ScriptLinkController API you should see a screen like this.
Screenshot of the ScriptLinkController Debugging in Mozilla Firefox 70
ScriptLinkController Debugging in Mozilla Firefox 70
  1. Confirm and copy the URL of your WSDL. Mine is: http://localhost:####/api/v3/ScriptLinkController.asmx?WSDL
Screenshot of the ScriptLinkController WSDL displayed in Mozilla Firefox version 70.
The content of the ScriptLink WSDL displayed in Mozilla Firefox v.70.

Setup Requests in Postman

Next, we will launch SoapUI and import our WSDL into a new test project.

  1. Launch Postman.
  2. Select File->Settings.
  3. If SSL certificate verification is on, turn off. This will prevent Postman form working with our self-signed certificate from Visual Studio.
Screenshot showing the Postman interface.
Postman Settings Interface
  1. Select New in the Task bar and Select Collection.
Screenshot showing the Create New interface in Postman.
Create New interface in Postman.
  1. Enter a Collection Name and optionally a description.
  2. Select Create.
Screenshot showing Create a New Collection in Postman.
Create a New Collection in Postman
  1. Once created, select Add requests from your collection’s documentation pane.
Screenshot showing the Collection Pane in Postman.
Collection Pane in Postman
  1. Enter GetVersion as the Request name and optionally a description.
  2. Select Save to [Collection Name].
Screenshot showing Adding the GetVersion Request to Postman.
Adding the GetVersion Request to Postman
  1. Add another request named Default Request.
Screenshot showing the Initial ScriptLink Tests in Postman
Initial ScriptLink Tests in Postman
  1. Expand GetVersion and select Open in builder.
  2. Paste the WSDL URL into the Enter request URL field.
  3. Set the request method to POST.
  4. Select Body->raw and set the body type to XML.
  5. Enter your SOAP request XML as follows.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetVersion/>
   </soapenv:Body>
</soapenv:Envelope>
  1. Select the Header tab and change the Content-Type to text/xml.
  2. Open the Default Request in builder.
  3. Paste the WSDL URL into the Enter request URL field.
  4. Set the request method to POST.
  5. Select Body->raw and set the body type to XML.
  6. Enter your SOAP request XML as follows.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:RunScript>
         <tem:optionObject2015>
            <tem:EntityID>?</tem:EntityID>
            <tem:EpisodeNumber>0</tem:EpisodeNumber>
            <tem:Facility>?</tem:Facility>
            <tem:Forms>
               <!--Zero or more repetitions:-->
               <tem:FormObject>
                  <tem:CurrentRow>
                     <tem:Fields>
		                <!--Zero or more repetitions:-->
                        <tem:FieldObject>
                           <tem:Enabled>?</tem:Enabled>
                           <tem:FieldNumber>?</tem:FieldNumber>
                           <tem:FieldValue>?</tem:FieldValue>
                           <tem:Lock>?</tem:Lock>
                           <tem:Required>?</tem:Required>
                        </tem:FieldObject>
                     </tem:Fields>
                     <tem:ParentRowId>?</tem:ParentRowId>
                     <tem:RowAction>?</tem:RowAction>
                     <tem:RowId>?</tem:RowId>
                  </tem:CurrentRow>
                  <tem:FormId>?</tem:FormId>
                  <tem:MultipleIteration>0</tem:MultipleIteration>
                  <tem:OtherRows>
                     <!--Zero or more repetitions:-->
                     <tem:RowObject>
                        <tem:Fields>
                           <!--Zero or more repetitions:-->
                           <tem:FieldObject>
                              <tem:Enabled>?</tem:Enabled>
                              <tem:FieldNumber>?</tem:FieldNumber>
                              <tem:FieldValue>?</tem:FieldValue>
                              <tem:Lock>?</tem:Lock>
                              <tem:Required>?</tem:Required>
                           </tem:FieldObject>
                        </tem:Fields>
                        <tem:ParentRowId>?</tem:ParentRowId>
                        <tem:RowAction>?</tem:RowAction>
                        <tem:RowId>?</tem:RowId>
                     </tem:RowObject>
                  </tem:OtherRows>
               </tem:FormObject>
            </tem:Forms>
            <tem:NamespaceName>?</tem:NamespaceName>
            <tem:OptionId>?</tem:OptionId>
            <tem:OptionStaffId>?</tem:OptionStaffId>
            <tem:OptionUserId>?</tem:OptionUserId>
            <tem:ParentNamespace>?</tem:ParentNamespace>
            <tem:ServerName>?</tem:ServerName>
            <tem:SystemCode>?</tem:SystemCode>
            <tem:SessionToken>?</tem:SessionToken>
         </tem:optionObject2015>
         <tem:parameter>?</tem:parameter>
      </tem:RunScript>
   </soapenv:Body>
</soapenv:Envelope>
  1. Select the Header tab and set the Content-Type to text/xml.
  2. You should now have both of your requests configured and ready to test.
Configured Requests Shown in Postman
Configured Requests Shown in Postman

Ok. Let’s run some tests.

Testing the API

For our first test, we are going to see what happens when we submit the GetVersion request.

Test #1: GetVersion

Our first test will be relatively straightforward. We want to get our GetVersion string back. When we created the SOAP project, SoapUI created default requests for us.

  1. Select the GetVersion tab.
  2. You should now see our XML request displayed and ready for submission.
Configured Requests Shown in Postman
Configured Requests Shown in Postman
  1. Select Send to submit request.
  2. You should have received an XML response.
Screenshot of the ScriptLink GetVersion Test Results in Postman
ScriptLink GetVersion Test Results in Postman

If the test was successful, then you should see the version number you set previously displayed in the GetVersionResult tag. If not, make sure your web application is still running.

Test #2: Submitting Default OptionObject

Ok. Now for the real test.

  1. Select the Default Request tab.
  2. You should now see our XML request displayed and ready for submission.
Screenshot showing the ScriptLink Default RunScript Request in Postman
ScriptLink Default RunScript Request in Postman
  1. Select Send to submit the request.
  2. You should have received an XML response with the ErrorCode “3” and the ErrorMesg “Hello, World!”
Screenshot showing the ScriptLink Default RunScript Response in Postman.
ScriptLink Default RunScript Response in Postman

Save Your Postman Requests

To help with future testing, let’s save our Postman request. You can close each tab and select Save changes. This should eliminate the need to configure the request again, unless we change ports.

Happy Testing

There you go. You are all set to set testing your ScriptLink APIs with SoapUI. Enjoy!

Advertisement

One reply on “Testing Your ScriptLink API with Postman”

Comments are closed.