Class: com.sybase.djc.rest.RestService (REST Service) EAServer 6.3 Help
Description Defines a service accessible through a REST (Representational State Transfer) style interface. A service is a business method defined on a CORBA stateless component or EJB stateless session bean, which is exposed for access via HTTP GET and POST.

Clients access services using URLs of the form:

      http://my-host:8000/rest/public-protected/representation/service-name
      
where:
  • public-protected is "public" or "protected", depending on the accessControl configured for the service.
  • representation is "help", "html", "json", "text", "xhtml-1.0", "xhtml-1.1", "xml-1.0" or "xml-1.1". This indicates the representation required for the HTTP response.

Regardless of the requested response representation, request parameters can be passed in one of three ways.

  1. For HTTP GET and POST, parameters can be passed in the query string, e.g. ".../rest/public/html/myService?firstParam=1&secondParam=2".
  2. For HTTP POST, parameters can be passed as form data using a Content-Type of "application/x-www-form-urlencoded".
  3. For HTTP POST, parameters can be passed as request content using an XML element (see requestElement). In this case, the content type must be something other than "application/x-www-form-urlencoded". It is recommended to use a Content-Type of "application/xml" in this case.

It is recommend to use the Set Properties Task to define REST services, although for prototyping purposes a minimal administrative web interface is available at a URL such as the following (vary the host and port according to your server's listeners).

      http://my-host:8000/rest/admin
      

Clients can obtain help for invoking protected services at a URL such as the following.

      http://my-host:8000/rest/protected/help
      

Clients can obtain help for invoking public services at a URL such as the following.

      http://my-host:8000/rest/public/help
      
Configuration See Set Properties Task.
Properties accessControl, allowCaching, cacheControl, componentMethod, namingStyle, parameterNames, requestElement, responseElement, resultName
Files Repository/Instance/com/sybase/djc/rest/RestService/*.properties

Property: accessControl (Access Control)
Description Specifies the primary access control mechanism for this service:
public
All public web clients can access this public service through the "/rest/public/" context path.
password
Web clients using HTTP basic authentication can access this protected service through the "/rest/protected/" context path.
certificate
Web clients using SSL/TLS with a trusted client certificate can access this protected service through the "/rest/protected/" context path.
deny
No clients can access this service.
Role based access control checks that are separately configured for the underlying business method will also be applied. Unauthenticated clients accessing public services will be treated as the user "[unauthenticated]" within the server.
Legal Values public, password, certificate, deny

Property: allowCaching (Allow Caching)
Description Allow clients to cache the response from a call to this service.
Default Value false
Legal Values false, true

Property: cacheControl (Cache Control)
Description Contents for the HTTP Cache-Control header that will be sent to clients in the HTTP response.
Only Used If Property allowCaching has the value "true".
Default Value max-age="3600"

Property: componentMethod (Component Method)
Description Fully qualified name of the component method name that implements this service, e.g. "ejb.components.example.MyCompRemote.myMethod" (using EJB remote interface) or "ejb.components.example.MyCompLocal.myMethod" (using EJB local interface) or "ejb.components.example.MyComp.myMethod" (using service endpoint interface).

To be exposed as a REST service, a method must follow the following rules:

  • It must not be an overloaded method.
  • It must not use 'inout' or 'out' mode parameters. All results of the service must be contained within the return value. Methods can return "void".

Property: namingStyle (Naming Style)
Description Specifies the mapping style from Java identifiers to XML element names. This is used when Java serializable classes (or IDL structure types) are used as method parameter or result types. The "default" naming style leaves names unchanged.

Note: the naming style is applied to field names, array "item" names, parameter and result names, and the request and response elements. For example, if you set resultName to "xyz", and namingStyle to "upperCamelCase", the actual resultName used will be "Xyz".

Default Value default
Legal Values default, lowerCamelCase, upperCamelCase

Property: parameterNames (Parameter Names)
Description A comma-separated list that allows overriding of the default method parameter names.
  • For CORBA components, the default parameter names are taken from the IDL interface definition.
  • For EJB components, the default parameter names are "p1", "p2", etc. Original Java method parameter names are not available as defaults because Java class files do not generally retain method parameter names.

Property: requestElement (Request Element)
Description If the client invokes the service with an XML request, the request parameters must be contained within an element of this name, e.g. if requestElement is "myRequest", the HTTP request content should be of the form:
        <myRequest>
          <p1>value1</p1>
          <p2>value2</p1>
          ...
        </myRequest>
        

Property: responseElement (Response Element)
Description If the client invokes the service expecting an XML response, the result value must be contained within an element of this name, e.g. if responseElement is "myResponse", the HTTP response content should be of the form:
        <myResponse>
          <result>value</result>
        </myResponse>
        

Property: resultName (Result Name)
Description Allows overriding of the default method result name (which is "result"). For "void" methods, this property is ignored. For methods returning a structure type (Serializable object), resultName is ignored as the response element will directly contain the result's fields.
Default Value result