Expand my Community achievements bar.

ReviewAndCommenting Service - Getting BLOB data over HTTP in .NET

Avatar

Level 2

Hi,

I am trying to invoke the ReviewAndCommenting service using BLOB data over HTTP in a .NET project.
I am setting the remoteURL property of the BLOB object to pass the document to the service.Though it picks up the document and gets back a document, it gives error saying -
"There was an error opening this document.The file is damaged and could not be repaired."

What are the steps required to get the return the editable document from "ReviewAndCommenting" service using remoteURL.

Here is the piece of code that I use to get the output

'-----------------------------------------------------------------------------------------------------------------------------------------------------------------


adobeLiveServiceInputBLOB.remoteURL = "http://localhost/ADOBELIVE/Test.pdf"
adobeLiveServiceInputBLOB.contentType = "application/pdf"
adobeLive.Credentials = userCredential 'assign the approppriate credentials

'Get the output BLOB
adobeLiveServiceOutputBLOB = adobeLive.invoke(adobeLiveServiceInputBLOB)


Dim uri As UriBuilder
uri = New UriBuilder(adobeLiveServiceOutputBLOB.remoteURL)

          'Convert the uriBuilder to a stream
            Dim wr As System.Net.WebRequest = System.Net.WebRequest.Create(uri.Uri)
            Dim res As System.Net.WebResponse = wr.GetResponse()

Dim sr As StreamReader
            sr = New StreamReader(res.GetResponseStream())
            Dim myStream As Stream
            myStream = sr.BaseStream

Dim byteData As Byte() = New Byte(BUFFER_SIZE) {}


Dim outPutDocFileName As String="D:\\AdobeLiveCyclePOC\\Annotated\\Annotated.pdf"

Dim fs As New System.IO.FileStream(outPutDocFileName, FileMode.OpenOrCreate)

            'Create a binayry writer
            Dim bw As BinaryWriter = New BinaryWriter(fs)

            bw.Write(byteData)
            bw.Close()
            fs.Close()

   'Populate the byte array              
    PopulateArray(myStream, byteData)


Private Shared Sub PopulateArray(ByVal stream As Stream, ByRef data As Byte())
        Dim offset As Integer = 0
        Dim remaining As Integer = data.Length
        Dim read As Integer
        While remaining > 0
            read = stream.Read(data, offset, remaining)
            If read <= 0 Then
                Throw New EndOfStreamException()
            End If
            remaining -= read
            offset += read
        End While
    End Sub

'----------------------------------------------------

Please can you help me resolve this?

1 Reply

Avatar

Level 2

Hi,

I tried reading from a separate webservice to read from a pdf file and write to another file.This is going through fine.

From the return blob,I could also get the file through base64 by specifying suffix value as ?blob_type=base64.This though is writing and creating the file, i am not able to open the newly created pdf file,though from the file size i presume that it has  some data in it returned by the ReviewAndCommenting service.

But on openeing , it gives an error "There was an error opening this documnt.There was a problem reading this documenr (131).

Is there any problem with the adobe live service service writing the data.

Thanks,