To export the service in server side, you should do the following
steps:
- Create the proxy:
- Use a interface on the client side. Here is an example:
public interface TestServiceInterface {
public String getYear(String name);
public void setYear(String name, String year) throws TestException;
}
- Implement the service interface on the server side. Here is
an example:
public class TestService implements TestServiceInterface {
private Map< String, String> values = new HashMap< String, String>();
public String getYear(String name) {
return values.get(name);
}
public void setYear(String name, String year) throws TestException {
System.out.println("name: " + name + " age: " + year);
if (name.equals(year)) {
throw new TestException("name: " + name + " age: " + year);
}
values.put(name, year);
}
}
- Configure the web container, which is the second level container
on the server side. To enable Remote on the server side, you should do the
following steps:
- Add some parameters and a listener for the service connector.
For example:
<context-param>
<description>
</description>
<param-name>elementFactoryConfigPath</param-name>
<param-value>jar:///universalFactory.xml</param-value>
</context-param>
<listener>
<description>Start BTT Server Components</description>
<display-name>BTTServerStarter</display-name>
<listener-class>com.ibm.btt.webapp.BTTServerStarter</listener-class>
</listener>
The elementFactoryConfigPath parameter indicates the path of
the BTT configuration files. The BTTServerStarter, which is provided by Remote,
is a listener which can be notified when web server started
- Add a servlet, which serves as the handler for the remote invocation.
For example:
<servlet>
<description>BTT Remote Connector Servlet</description>
<display-name>BTTRemoteConnector</display-name>
<servlet-name>BTTRemoteConnector</servlet-name>
<servlet-class>com.ibm.btt.remote.BTTRemoteConnector</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BTTRemoteConnector</servlet-name>
<url-pattern>/BTTRemoteConnector</url-pattern>
</servlet-mapping>
Note: Those four jars library at runtime are needed on the client
side:
- commons-codec-1.3.jar
- commons-httpclient-3.1.jar
- commons-logging-1.1.1.jar
- commons-logging-api-1.1.1.jar
You can find them at: <BTTInstallationPath>\plugins\com.ibm.btt.remote_6.1.2\lib\