This recipe will guide you through a sample implementation of a proxy service which polls a directory for XML files compressed using the gzip
utility, and uses the Java wrapper created in the previous recipe, to convert it to standard XML which can then be manipulated as normal within the OSB.
This recipe assumes you have completed the first recipe and created the GzipAdapter.jar
. Alternatively, you can use the Jar file contained with the samples for this recipe.
Prior to beginning this recipe, you will also want to prepare some test data, consisting of XML files compressed using GZIP.
GzipFileAdapter
if you want to follow the example used in this recipe.GzipAdapter
jar plus any of its dependencies into the project. Right-click on the GzipFileAdapter OSB Project in the Project Explorer, and select New Folder from the context menu.Enter the name jars
for the folder and click on Finish.
Browse to the modules
directory under <FMW Home>modules
and click on OK. Within the import window select com.bea.core.xml.xmlbeans_2.2.0.0.jar
(as used earlier in the first recipe), and then click on Finish.
Browse to the directory containing the GzipAdapter.jar
, created in the first recipe, and click on OK. Within the import window, select GzipAdapter.jar
and click on Finish.
GzipAdapter.jar
in Project Explorer. In the Modify Jar Dependencies dialog box, select com.bea.core.xml.xmlbeans_2.2.0.0.jar
file from the Available jars pane on the left, and click on the Add > button to move it to the Jar references pane. Click on OK.Right-click on the GzipFileAdapter
OSB project in Project Explorer and select New | Proxy Service. Name it ReadGzipFile
and click on Finish.
*.gz
, as well as configuring a Post Read Action to be archive and specifying all the necessary directory file destinations.readGzipObject
Java method into the proxy service Message Flow.Start by dragging a new Pipeline Pair from the Design Palette into the Message Flow editor.
Extract GZIP
.$body/ctx:binary-content
and the Variable as gzBinaryContent
.GzipAdapter.jar
and click on OK.In the Select a Java Method window, select the readGzipObject
method and click on OK.
$gzBinaryContent
. Set the Result Value variable to payload
.i. Create a new Reporting stage below the GZIP Extract
stage and drag a new Log action in.
ii. Set the log Expression as $payload
and the Annotation as GzipFileAdapter message payload
.
iii. Change the Severity to Error
so that it is guaranteed to appear on your weblogic's console output.
iv. Deploy the service to your server, copy a GZIP'd text file to the input directory you specified earlier, and observe that the contents are written to the console.
OSB's binary message format capability allows us to accept files of any type, and extract the binary content using the built-in constructs which are generated by the engine.
From there, the Java Callout allows us to manipulate and parse the content using standard libraries. Note, that the return type from the Java Callout is org.apache.xmlbeans.XmlObject
, the standard XMLBeans interface which OSB uses to manipulate XML. By using this return type (as opposed to a String
) we are able to immediately start manipulating the returned content as XML using all the standard OSB message processing actions.
In some cases, multiple files may be included in the same compressed archive. There are a couple of viable strategies for manipulating these files using OSB: