cancel
Showing results for 
Search instead for 
Did you mean: 

Web Services Publishing - Upload File via Unity Script

Srimanth_Nerall
Champ in-the-making
Champ in-the-making
Is there a ability to upload a file into OnBase using Web Services Publishing [Unity Script]?Hyland.Unity.EnterpriseIntegrationServer.EISScriptEventArgs has InputMessageDocument to send the input XML/ JSON to the service unity script. In addition, can the unity script has the ability to read the byte stream from the request object?
Below is the sample client code in .net to invoke a REST WCF service to pass the file stream to be uploaded.

How can the unity script receive the File steam object to be uploaded into OnBase?byte[] bytearray=null ;string name = "";//throw new NotImplementedException();if (FileUpload1.HasFile){name = FileUpload1.FileName;Stream stream = FileUpload1.FileContent;stream.Seek(0, SeekOrigin.Begin);bytearray = new byte[stream.Length];int count = 0;while (count < stream.Length){bytearray[count++] = Convert.ToByte(stream.ReadByte());} }string baseAddress = "http://" + Environment.MachineName + ":8000/Service/FileUpload/";HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(baseAddress+name);request.Method = "POST";request.ContentType = "text/plain";Stream serverStream = request.GetRequestStream();serverStream.Write(bytearray, 0, bytearray.Length);serverStream.Close();using ( HttpWebResponse response = request.GetResponse() as HttpWebResponse ){int statusCode =(int) response.StatusCode;StreamReader reader = new StreamReader( response.GetResponseStream() ); }

Appreciate your help!

Thank you!
Srimanth
1 ACCEPTED ANSWER

Naveen_Kandakum
Confirmed Champ
Confirmed Champ

Web Services Publishing can accept strings as input or base64. Input the same to the Unity Script and you can achieve it. We don't support byte stream.

 

You can also use HIS Workflow XML Messaging to use OffRamp to download the document to a temporary folder and create the document inside Onbase. Which will have less coding and more of a workflow logic.

 

Thank You,

Naveen

View answer in original post

6 REPLIES 6

Naveen_Kandakum
Confirmed Champ
Confirmed Champ

Web Services Publishing can accept strings as input or base64. Input the same to the Unity Script and you can achieve it. We don't support byte stream.

 

You can also use HIS Workflow XML Messaging to use OffRamp to download the document to a temporary folder and create the document inside Onbase. Which will have less coding and more of a workflow logic.

 

Thank You,

Naveen

Thanks Naveen for the response!

 

I think I can try to pass base64 string as input to the unity script, within the script, I can try to convert the base64 to byte stream, which can be used to create the document to be imported into OnBase.

 

With that I think we can avoid HIS Workflow XML Messaging. Can you please confirm?

Justin_Carlson
Employee
Employee

@Srimanth Neralla In your question it sounds like you are using the WSP operation to execute a Unity script, and wanting to pass in a file as the input. Is there a reason you couldn't use the out of the box CreateDocument action for WSP? Then you wouldn't need to worry about writing a Unity Script to read the byte data, you would simply need to format the input to the web service correctly.

The unity script is further making a communication with an external webservice to get the data, the obtained data needs to be further passed to the original OnBase web service client.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.