Download a file securely from oracle OCI , need help with java service, Please help

Did any one downloaded a file from Oracle OCI environment through a secure link.

Here are the steps i need to perform:
• Generating an API Signing Key (already completed):
o ** **
• Signing the HTTP requests:
o ( need help with this java code to use it in webmethods)
o Request Signatures
• GetObject route to download the file:
o Oracle Cloud Infrastructure API Reference and Endpoints

Can someone from Java please help me to use this code in webmethods,
code ( ( need help with this java code to use it in webmethods)

here is sample code

  • Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
  • This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at
  • or Apache License 2.0 as shown at You may choose either license.
    import java.nio.charset.StandardCharsets;




public class RawRestCallExample {

public static void main(String args) throws Exception {
// TODO: fill this out
String instanceId = null;

String configurationFilePath = “~/.oci/config”;
String profile = “DEFAULT”;

// Pre-Requirement: Allow setting of restricted headers. This is required to allow the SigningFilter
// to set the host header that gets computed during signing of the request.
System.setProperty(“”, “true”);

// 1) Create a request signing filter instance
RequestSigningFilter requestSigningFilter =
RequestSigningFilter.fromConfigFile(configurationFilePath, profile);

// 2) Create a Jersey client and register the request signing filter
Client client = ClientBuilder.newBuilder().build().register(requestSigningFilter);

// 3) Target an endpoint. You must ensure that path arguments and query
// params are escaped correctly yourself
WebTarget target =“”)

// 4) Set the expected type and invoke the call
Invocation.Builder ib = target.request();
Response response = ib.get();

// 5) Print the response headers and the body (JSON) as a string
MultivaluedMap<String, Object> responseHeaders = response.getHeaders();
InputStream responseBody = (InputStream) response.getEntity();
try (final BufferedReader reader =
new BufferedReader(new InputStreamReader(responseBody, StandardCharsets.UTF_8))) {
StringBuilder jsonBody = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {

HI Garu,

What’s the error you’re getting?
I would propose to

  1. develop simple java app for secure file download from Oracle OCI. Hope Oracle documentation is straight forward and it should be easy
  2. Once you have the code from 1) it should be easier to integrate it within webMethods

Hope that helps

Some forum participants might object to this suggestion, but one approach to consider is to not use Java,*, Jersey, etc as the core components. Do this in an “Integration Server” way, not a Java way. It is likely you can create the payload and headers directly without too much effort. You may need a Java service or 2 for a specific part, but certainly do not need a single Java service that does everything. Break it up into logical bits to create the payload, sign it, generate the headers, etc. then use pub.client:http for the HTTP call – there is no reason to be making the HTTP call using Java code. There are other built-in services that may help with payload signing and such. Leverage the tools IS provides.

We did something similar to this to put data to WebCenter Content (WCC) hosted on OCI, though it is SOAP-based, not JSON over HTTP. We found it much easier to create the payload using string-manipulation, var substitution, etc. rather than fighting with the WSD created from the WCC WSDL. Using string templates where appropriate and setting HTTP headers ourselves resulted in a far simpler/understandable approach. Not as flexible for future use/changes but we didn’t need that. You may find this approach is easier for your needs as well.