Replacement of Packages.java.io.ByteArrayOutputStream() for writing byte array over SOAP

Gursimran Sing1
Kilo Contributor

What is the replacement of Packages.java.io.ByteArrayOutputStream() for New York version?

We have custom integration with Third party tool. After the upgrade to NewYork, attachments are not passing over SOAP

It is giving below error::
Error MessageIllegal access to method writeTo(java.io.ByteArrayOutputStream) in class com.glide.ui.SysAttachmentInputStream

var attachmentIS = new GlideSysAttachmentInputStream(attachsys_id);
var bytearrayOS = new Packages.java.io.ByteArrayOutputStream();
attachmentIS.writeTo(bytearrayOS);
var content64 = GlideBase64.encode(bytearrayOS.toByteArray());

Can anyone suggest API/function for the replacement of Packages.java.io.ByteArrayOutputStream().

1 ACCEPTED SOLUTION

florin_danis
Kilo Expert

Hi Gursimrun,

It seems ServiceNow changed the signature for the 'writeTo' method.
Try to use "attachmentIS.writeTo(bytearrayOS, 0, 0);" instead of "attachmentIS.writeTo(bytearrayOS);".

Example in the oob script: /sys_script.do?sys_id=468eebfeff447300c2e8a897d53bf16e

I hope this solved your issue.

View solution in original post

5 REPLIES 5

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

Is this scope application?

If yes then see this: https://community.servicenow.com/community?id=community_question&sys_id=332f47e1dbdcdbc01dcaf3231f96...

 

Thanks,
Ashutosh

Gursimran Sing1
Kilo Contributor

Thanks Ashutosh,

 

This is Global application. I tried using getBytes from glideSysAttachment , attachment is going through integration - file name and content type , but content/payload is not going. I think there is a problem in attachmentIS.writeTo(bytearrayOS); - how to write byte array on SOAP in NewYork, any guess?

Hi Gurismran, 

Can you share more details about the use case and how you're using the attachment with the SOAP call? Is the entire SOAP envelope in the attachment, and this is sent as the payload? Are you using SOAPMessageV2? 

florin_danis
Kilo Expert

Hi Gursimrun,

It seems ServiceNow changed the signature for the 'writeTo' method.
Try to use "attachmentIS.writeTo(bytearrayOS, 0, 0);" instead of "attachmentIS.writeTo(bytearrayOS);".

Example in the oob script: /sys_script.do?sys_id=468eebfeff447300c2e8a897d53bf16e

I hope this solved your issue.