This chapter explains how to build and run the sample socket transport provider. This sample is installed along with Oracle Service Bus. The sample serves as an example implementation of a custom transport provider and the sample source code is available to you.
The primary purpose of the sample socket transport provider is to serve as an example transport provider implementation. This publicly available sample demonstrates the implementation and configuration details of the Transport SDK.
The sample transport is designed to send and receive streamed data to and from a configured TCP socket in Oracle Service Bus. The sample transport is intended to illustrate the following Transport SDK concepts:
Implementing the set of Transport SDK APIs that are required to build a custom transport.
Performing transport endpoint validations, such as checking that no socket endpoint is listening on the configured address.
Implementing several UI configuration options, including socket properties and message patterns.
Implementing a one-way or synchronous request-response message pattern.
Using POJOs (Plain Old Java Objects) for metadata and headers of endpoint requests and responses.
Showing how streaming is used in the Oracle Service Bus pipeline.
Basic Architecture of the Sample
Figure 6-1 shows the basic architecture of the sample socket transport provider. Any client can connect to the server socket. Data is received at the server socket and passes through the pipeline. The response comes back through the outbound transport. The response is finally sent back to the inbound transport and back to the client.
Figure 6-1 Sample Socket Transport Architecture
Configuration Properties
Figure 6-2 illustrates the configuration properties for the transport endpoint. These properties are configured in the schema file: SocketTransport.xsd. See Sample Location and Directory Structure for information on the location of this file. This file allows you to extend the basic set of properties defined in the common schema provided with the SDK. Refer to the SocketTransport.xsd file for information on each of the properties.
Also in the SocketTransport.xsd file are the request/response header and metadata properties, as illustrated in Figure 6-3. Refer to the SocketTransport.xsd file for more information on these properties.
Figure 6-3 Request/Response Header and Metadata Configurations
Sample Location and Directory Structure
The sample socket transport provider is installed with Oracle Service Bus and is located in the following directory:
ALSB_HOME/samples/servicebus/sample-transport
Figure 6-4 shows the directory structure for the sample socket transport provider. This section briefly describes the folders in the sample project. You can use this directory structure as a model for developing your custom transport provider.
Figure 6-4 Sample Transport Project Structure
Table 6-1 lists and briefly describes the sample-transport directories.
Table 6-1 Sample Transport Provider Directories
build
Created when you build the sample socket transport. Contains the built and packaged transport for use in Oracle Service Bus.
config
Configuration files directory.
SocketConfig.xml – Socket transport provider configuration that is used by the Transport SDK.
eclipse
Contains the plugin.xml file needed to add the sample transport to the Workshop for WebLogic environment.
help
l10n
Contains Internationalization files:
SocketTransportMessages.xml – Configuration file for text messages which are displayed on the Oracle Service Bus Console.
Contains the deployment descriptors required for the sample transport help Web application.
The following Ant build files are also located in the sample-transport directory:
build.properties – Properties file for Ant.
build.xml – An Ant build file with different targets for compile, build, and deploy.
Building and Deploying the Sample
This section explains how to build and deploy the sample transport provider.
Setting Up the Environment
Create a new domain or use one of the preconfigured domains that are installed with Oracle Service Bus.
Set the domain environment by running the following script:
DOMAIN_HOME/bin/setDomainEnv.cmd (setDomainEnv.sh on a UNIX system)
Building the Transport
To build the socket transport, do the following:
In a command window, go to the sample home directory:
ALSB_HOME/samples/servicebus/sample-transport
Execute the following command: ant build-jar
This command compiles the source files and does the following:
Creates sock_transport.ear and copies it to BEA_HOME/ALSB_HOME/lib.
Creates /sample-transport/build/Socket_Transport_3.0.0.0.jar as a plug-in to Workshop for WebLogic and copies it to ALSB_HOME/eclipse/plugins.
Deploying the Sample Transport Provider
To deploy the sample transport provider on a server, do the following:
Set the following variables in sample-transport/build.properties:
wls.hostname
wls.port
wls.username
wls.password
wls.server.name
Deploy the transport provider on the server by running the following command:
ant deploy
Start and Test the Socket Server
The sample project includes a simple socket server and a client to test the server. You can use this socket server to test the socket transport provider.
port – The port number at which ServerSocket is listening, which is the port number in the business service.
message-file-location – (optional) The location of the message-file which will be sent as a response to the business service.
file-encoding – A system property that is the encoding of the file. (default = utf-8)
request-encoding – The encoding of the request that is sent by the socket business service. (default = utf-8)
Test the Socket Transport
Run the following command to start the service, which is a client to a configured socket proxy-service. It sends a message and receives the response from Oracle Service Bus.
host-name – The host name of the Oracle Service Bus server.
port – The port number at which the proxy service is listening.
thread-ct – The number of clients that can send a message to Oracle Service Bus.
message-file-location – (optional ) The location of the message file that will be sent as a response to the business service.
file-encoding – An optional argument specifying the encoding of the file. (default = utf-8)
response-encoding – The encoding of the response received from the socket proxy service. (default = utf-8)
Configuring the Socket Transport Sample
The sample consists of a test server and a test client. The client sends a message to the server. You configure Oracle Service Bus to receive and process the message.
In the SocketProxy row of the Resources table, click the Launch Test Console icon, as shown in Figure 6-13.
Figure 6-13 Starting the Test Console
In the Test Console, enter any valid XML stanza in the text area, or use the Browse button to select a valid XML file on the local system. For example, in Figure 6-14, a simple XML expression <x/> is entered in the text area.
Figure 6-14 Test Console
Click Execute. If the test is successful, information similar that shown in Figure 6-15 appears in the Test Console. In addition, the XML text input into the Test Console is echoed in the server console.