Sending byte[] from Java (HTTP-POST) to IS flow service.

Greetings,

I have a scenario in my current project where i have my java application and on integration server a flow service (pub.file:bytesToFile). I have to send a file (zip) and store it on the integration server. I’m using HttpURLConnection from my java application for this as follows:


connection = dp.query.getHttpConnection("pub.file:bytesToFile", null);
connection.connect();
            
try (DataOutputStream dos = new DataOutputStream(connection.getOutputStream())) {
    final String params = String.format("fileName=%s&bytes=%s", "Testfile.zip", URLEncoder.encode(new String(file), "UTF-8"));
    dos.writeBytes(params);
    dos.flush();
}

file is the bytes of the file to be uploaded. So it’s more like a byte file;

I have the content type url-encoded. The response however i get from the IS says that the bytes parameter is not a byte.
Relevant part:


<TR>
<TD valign="top"><B>$error</B></TD>
<TD>[ISS.0086.9250] Parameter [bytes] is not of type: [byte[]]</TD>
</TR>
<TR>
<TD valign="top"><B>$errorType</B></TD>
<TD>com.wm.app.b2b.server.ServiceException</TD>
</TR>

I can’t use any other service which means I have to utilize this current scenario on some way, but if there’s other
built-in service that can upload files to given place that might be an alternative option.

Is there any way to post byte from java to this bytesToFile service?

The purpose of this project:
We don’t have file system access to our ISes as developers. In order to deploy packages we have to copy the package zip files to replicate/inbound folder. Since we don’t have file system access we need a way to copy the zip file to the replicate/inbound folder without self made flow services since that wouldn’t solve anything. For that we need to copy that package to the other IS-es. The project’s short term scope is to use built-in package to upload this (validated) zip file to the IS.

Thanks,
Jozsef

One hint for the future: Start with the problem you are trying to solve, not with the solution you tried so far, because:

If this is just about deploying packages to a remote server, you are doing way to much overhead. Integration Server can deploy packages to each other.

  • Alternative 1: make the server you want to deploy to a subscriber to the one where the package is coming from. This is done in the IS admin console, under packages: publishing and subscribing.
  • Alternative 2 (preferred one): Use Deployer. Deployer can retrieve and publish packages (and all other wm assets) from and to remote servers.

For file transfer beside that: IS can open FTP and (in the recent versions) SFTP ports. Those can deliver to a service directly or write to the local file system and publish a notification message about the arrivel.