9 1 Using the RFIService client class

LANSA Integrator

9.1 Using the RFIService client class

RFIService is the client class used for Remote Function Invocation programming.

To create an instance of RFIService use the static getInstance method. This method requires a properties parameter. These properties control the communication characteristics of the host connection.

Property

Comments

rfi.server

Host protocol and address http://your.own.url:port.

rfi.proxy

Proxy server.

rfi.user

Basic authentication user.

rfi.password

Basic authentication password.

rfi.agent

Host agent program.
Default - /cgi-bin/jsmdirect.

rfi.protocol.encoding

HTTP protocol head encoding.
Default - ISO8859_1.

rfi.authentication.encoding

HTTP Basic authentication encoding.
Default - ISO8859_1.

rfi.server.trusted

Required for an SSL connection if the trust store does not contain the peer certificate.
A value of true means that server certificate will be trusted.

 

Example

 

Properties properties = new Properties () ;

 

properties.put ( "rfi.server", "http://your.own.url:port" ) ;

 

RFIService service = RFIService.getInstance ( properties ) ;

 

The RFIService has two methods to send and receive serialized objects.

The getObject method is used to receive a serialized response object from the host server using the specified service name.

 

Object getObject ( String service ) 

Object getObject ( RFIObject service ) ;

 

Example

 

Object object = service.getObject ( "EMPLOYEE-FETCH" ) ;

 

The putObject method sends a serialized object to the host server and receives a response object from this named service.

 

Object putObject ( String service, Object sendObject ) ;

Object putObject ( RFIObject sendObject ) ;

 

Example

 

Object object = service.putObject ( "EMPLOYEE-UPDATE", employee ) ;

 

If the response status from the host is not successful then an RFIException is thrown.

If the content type of the response is not "application/x-java-serialized-object" an RFIException is thrown.

If no content was returned a null object reference is returned, else the content is de-serialized and an object reference is returned.

The RFIObject interface has one method to return the service name.

This allows the sendObject to supply the name of the service and eliminates the need for the String service name parameter.

 

public interface RFIObject

{

    public String getService () ;

}

 

The RFIException class has several methods to allow access to the response status and message.

Method

Comments

int getStatus ()

Get response status code

String getMessage ()

Get response status message

byte[] getContent ()

Get response content

Enumeration propertyNames ()

Get response properties

getProperty ( String property )

Get response property