User Guide > Tasks > Working with Cloud Connected Mobile > Adding and Testing a New Method Route

Adding and Testing a New Method Route

The following procedures explain how to add and test new RPC or RESTful API services to the Zend Server Gateway using the 'gateway.xml' graphical editor.

Adding a New RPC Method Route

This procedure describes how to add a new RPC API method to the Zend Server Gateway.

 

 

Instructions on how to complete a procedure

To add an RPC route:

  1. In the PHP Explorer, open the 'config' folder of your CCM server-side project, and select the 'gateway.xml 'file .
    The file is displayed in a graphic editor.

  1. From the Handlers list on the right, drag the RPC Service, and drop it in the center of the editor.
    The Add New RPC Service dialog is displayed.

  1. Enter the following information:
  • URL - HTTP request URL (e.g., /users)
  • Method - Type of HTTP method (e.g., GET, POST, DELETE, etc.). Click drop-down menu to select a method.
  • Request Parameters - List of URL request parameters.
  • Add  Parameter - Click to add a URL request parameter. Select an existing parameter and click Remove to remove a request parameter.
  • Handler Method - PHP class method to be executed when HTTP request is sent. Click Browse to select a class method. Click Handler Class to view in controller file.
  • Requires Authentication - Select this check-box for requiring authentication for requests to this service. This option is only available once you have added authentication to the Gateway. For more information, see Adding and Testing Authentication.
  1. Click OK.
    The new service route is added to the Zend Server Gateway 'src' folder, and is displayed in the graphic editor.

You can easily delete the new method route. To do this, hover over the route and click -OR- right-click the new route, and select Delete.

Adding a New RESTful Method Route

This procedure describes how to add a new RESTful API method to the Zend Server Gateway.

 

 

Instructions on how to complete a procedure

To add a RESTful route:

  1. In the PHP Explorer, open the 'config' folder of your CCM server-side project, and select the 'gateway.xml 'file .
    The file is displayed in a graphic editor.

  1. From the Handlers list on the right, drag the RESTful Service, and drop it in the center of the editor.
    The Add New RESTful Service dialog is displayed.

  1. Enter the following information:
  • URL - HTTP request URL (e.g.,/customer[/:id])
  • Request Parameters - List of URL request parameters.
  • Add URL Parameter - Click to add a URL request parameter. Select an existing parameter and click Remove to remove a request parameter.
  • Handler Class- PHP class method to be executed when HTTP request is sent. Click Browse to select a class method. Click Handler Class to view in controller file.
  • Requires Authentication - Select this check-box for requiring authentication for requests to this service. This option is only available once you have added authentication to the Gateway. For more information, see Adding and Testing Authentication.
  1. Click OK.
    The new service route is added to the Zend Server Gateway 'src' folder, and is displayed in the graphic editor.

You can easily delete the new method route. To do this, hover over the route and click -OR- right-click the new route, and select Delete.

Testing a Method Route

This procedure describes how to test a Zend Server Gateway RPC or RESTful API method.

Important:

Testing a method route can only be performed if you have already successfully deployed the application. In the PHP Explorer, open the 'deployment.xml' file and in the Testing area, click Deploy a PHP Application. For more information on deploying applications, see Working with Deployment.

 

 

Instructions on how to complete a procedure

To test a route using the graphic editor:

  1. In the PHP Explorer, open the 'config' folder of your CCM server-side project, and select the 'gateway.xml 'file .
    The file is displayed in a graphic editor.

  1. Right-click the route you wish to test, and select Test Service.
    The Test Service view is displayed.

  1. Review route details:
  • Validate the application URL that is displayed in the URL field (deployment target, project name and API name).
  • Validate the method type selected in the Method area (corresponds to the selected method in editor).
  1. Click .
    Results are displayed in the Response window.

You should receive a '200 OK' response. If you receive a '404 Not Found' error, make sure the URL at the top of the Test Service view is correct. If this problem persists, redeploy your server-side project.

 

 

Related Links

Related Links:

Cloud Connected Mobile

Configuring the Zend Server Gateway

Adding Validation to Method Routes

Adding and Testing Authentication

Procedural Configuration

Test Service View

 

 

 

©1999-2013 Zend Technologies LTD. All rights reserved.