PhpStorm 6.0.1 Web Help

PhpStorm provides facilities to test RESTful Web services by emulating interaction with them by composing and running requests, as if you were the application that actually calls the service.

Testing RESTful Web Services is supported via the REST Client bundled plugin, which is by default enabled. If not, activate it in the Plugins page of the Settings dialog box.

There are two main use cases when you need to compose and run requests to a RESTful Web service:

Testing a RESTful Web service includes the following checks:

PhpStorm enables you to run these checks from the REST Client tool window by composing and submitting requests to the local server, viewing and analyzing server responses.

If necessary, configure the Proxy settings on the HTTP Proxy page of the Settings dialog box.

On this page:

To compose and submit a test request to a Web service method
  1. If you are going to test your own Web service, make sure it is deployed and running.
  2. Choose Tools | Test RESTful Web Service. The REST Client dedicated tool window opens.
  3. Select the test request method from the HTTP method drop-down list. The available options are:
  4. Provide the data to calculate the URL address of the target method:
    1. In the Host/port text box, type the URL address of the host where the Web service is deployed.
    2. In the Path field, specify the relative path to the method to invoke.
  5. In the Header data pane, specify the technical data included in the request header. These data are passed through header fields and define the format of the input parameters (accept field), the response format (content-type field), the caching mechanism (cache-control field), etc.

    The set of fields and their values should comply with the Web service API. In other words, the specified input format should be exactly the one expected by the Web service as well as the expected response format should be exactly the one that the service returns.

    For accept, content-type, and some other fields PhpStorm provides a list of suggested values. Choose the relevant format type from the Value drop-down list.

  6. Create a set of parameters to be passed to the target method and specify their values. Depending on the chosen request method, you can create a list of parameters in two ways:
    • For GET requests, specify the parameters to be passed as a query string inside the URL. Use the Query string parameters pane. By default, the pane shows an empty list with one line. To add a parameter, type its name and value in the corresponding fields. As soon as you complete one parameter definition, a new empty line is added automatically.

      To suppress sending the specified query string parameters, select the Don't send anything check box. This may be helpful, for example, if you want to test passing parameters through other request methods in the request body but still preserve the data typed in the Query string parameters pane. Selecting the check box also disables the controls in the Query string parameters pane.

    • To have the parameters passed to the target method inside a request message body, use the the Request parameters pane. or have them inserted in the request from a local file.
      • To specify the parameters explicitly, choose the Text option and tpe the parameters and values in the text box.
      • To have the parameters inserted from a text file, choose the File contents option and specify the file location in the File to send field.
      • To have a binary file converted and sent in the request, choose the File upload(multipart/form-data) option and specify the file location in the File to send field.
    In either case, the set of parameters and their types should comply with the Web service API, in particular, they should be exactly the same as the input parameters of the target method.
  7. To submit a request to the server, click the Submit request button run.
To view and analyze responses from a web service, do one of the following:
  • To view the response to the server request, switch to the Response tab. The tab is opened automatically when a response is received. By default, the server response is shown in the format, specified in the request header through the content-type field.
  • To have the response converted into another format and opened in a separate tab in the editor, use the View as HTML classTypeHtml, View as XTML  classTypeXml, or View as JSON viewAsJSON buttons.
  • To view the technical data provided in the header of a Web service response, switch to the Response Header tab.

See Also

Reference:

External Links:

Web Resources: