Page Contents

Run and Test the Application

Congratulations! you are now ready to run and test your application.

Running the Application

npm start

You will see the following output:

Server is running at http://[::1]:3000

Test the Application

You can use your browser or any http client such as curl.

Warning: Make sure you are connected to the internet, since the SOAP web service is external.

curl http://localhost:3000/add/50/50

You will see the two properties in the response payload. The result property in JSON format and the envelope property in XML format.

The XML response is useful if you want to process the response in this format. However, if you are programming only in JSON format, focus only on the result property. Your client application will have access to result value using the normal convention result.AddResult and get the 100.

{"result":{"AddResult":100},"envelope":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"http://wsdl.example.org/\"><SOAP-ENV:Body><ns1:AddResponse><AddResult>100</AddResult></ns1:AddResponse></SOAP

Changing the listening URL and PORT number

Sometimes you want to restrict the IP address to which your application will be bind and its port number. You can use Object.assign in the src/application.ts constructor before the super(options); statement as follows:

options = Object.assign(
  {},
  {
    rest: {
      url: '127.0.0.1',
      port: 3000,
    },
  },
  options,
);

Previous step: Add a Controller