Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (52 sloc) 1.87 KB
lang title keywords sidebar permalink
en
Run and Test it
LoopBack 4.0, LoopBack 4
lb4_sidebar
/doc/en/lb4/soap-calculator-tutorial-run-and-test.html

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://127.0.0.1:3000
Try http://127.0.0.1:3000/ping

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.value and get the 100.

{"result":{"value":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-ENV:Body></SOAP-ENV:Envelope>

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,
);

Navigation

Previous step: Add a Controller

You can’t perform that action at this time.