Skip to Content
1

how to upload an external file to BO CMS via vb.net API

Nov 09, 2016 at 04:10 PM

131

avatar image

Hi all,

our customer wants to upload files (PDF, PowerPoint, Word and Excel documents) programmatically into the BO CMS. The aim is to use this as a publish feature, i.e. to make the files available in an authorized folder. All users with the role to Access the folder can view the file.


So far we have implemented the startUpload - oploadFile - finishImportUpload methods of the com.businessobjects.dsws.biplatform.BIPlatform object as described here:https://help.sap.com/javadocs/boe/xir2/ws/en/com/businessobjects/dsws/biplatform/BIPlatform.html

Unfortunately, we get an "couldn't find END tag" error in the finishImportUpload metohd (full exception see below). However, the file in the TEMP folder can be opened without problems.

Is the finishImportUpload method the right one to upload files to the CMS?

Thanks for your Input!

Thilo


CallStackTrace= at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at BusinessObjects.DSWS.BIPlatform.ConsumerBIPlatform.FinishImportUpload(String SessionID, String UploadID, String DestinationFolderCUID, ImportOptions Options)
at BusinessObjects.DSWS.BIPlatform.BIPlatform.FinishImportUpload(String uploadID, String importFolderCUID, ImportOptions options)
CauseException=SoapException
CauseMessage=Input/output exception occurred : 'Open failed for file 'C:\Windows\TEMP\28826JQDWk1z2nz0Xrt0VJgwvJbM%2CSI_TENANT_ID%3D0\AecVnIjVo3VHkz1QgoH8Ub4' with error message 'couldn't find 'END' tag'.' (FWM 04013)
HResult=-2146233088

ID=http://biplatform.dsws.businessobjects.com/2007/06/01/FinishImportUpload
Message=FinishImportUpload exception (Error: WBP 99999)
Operation=http://biplatform.dsws.businessobjects.com/2007/06/01/FinishImportUpload
Source=DSWS Web Service Consumer
WebServiceID=""
StackTrace:
at BusinessObjects.DSWS.BIPlatform.BIPlatform.FinishImportUpload(String uploadID, String importFolderCUID, ImportOptions options)
at com.biexcellence.openbi.DesignStudioExport.DesignStudioExportHandler.plublish2BO(IHttpResponse& iresponse, openbiExportSettings isettings)
InnerException:

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Bastian Buchholz Nov 10, 2016 at 09:15 PM
0

Thanks Karthik for the hints, we figured it out using the .NET API:

Dim lfilename = "test.pdf"
Dim lcontentType = "application.pdf"
Dim lstream As New FileStream(lfilename, FileMode.Open)

Dim lsession As BusinessObjects.DSWS.Session.Session = ...
Dim biPlatformURL As String() = lsession.GetAssociatedServicesURL("BIPlatform")

Dim lbi = BusinessObjects.DSWS.BIPlatform.BIPlatform.GetInstance(lbo.SessionObject, biPlatformURL(0))

Dim lresponseHolder As BusinessObjects.DSWS.BIPlatform.ResponseHolder = lbi.Get("path://InfoObjects/" & lpath, Nothing)
Dim lfolder = lresponseHolder.InfoObjects
Dim lparentCuid As String = lfolder.InfoObject(0).CUID
Dim lcuid As String = lbi.GenerateCuids(1)(0)

Dim lfileInfoObject As BusinessObjects.DSWS.BIPlatform.Desktop.InfoObject
Select Case Path.GetExtension(lfilename).ToLower
    Case ".pdf"
        lfileInfoObject = New BusinessObjects.DSWS.BIPlatform.Desktop.Pdf
    Case ".xls", ".xlsx"
        lfileInfoObject = New BusinessObjects.DSWS.BIPlatform.Desktop.Excel
    Case ".ppt", ".pptx"
        lfileInfoObject = New BusinessObjects.DSWS.BIPlatform.Desktop.Powerpoint
    Case ".doc", ".docx"
        lfileInfoObject = New BusinessObjects.DSWS.BIPlatform.Desktop.Word
    Case Else
        lfileInfoObject = New BusinessObjects.DSWS.BIPlatform.Desktop.Agnostic
        DirectCast(lfileInfoObject, BusinessObjects.DSWS.BIPlatform.Desktop.Agnostic).MimeType = lcontentType
End Select
lfileInfoObject.CUID = lcuid
lfileInfoObject.Name = lfilename
lfileInfoObject.ParentCUID = lparentCuid

Dim luploadStatus As BusinessObjects.DSWS.BIPlatform.UploadStatus = New BusinessObjects.DSWS.BIPlatform.UploadStatus()
luploadStatus.UploadID = lbi.StartUpload()

Dim lbuffSize = 32768
Dim lbyteCount = 0
Dim lnumBytes = lstream.Length
While lbyteCount < lnumBytes
    If ((lnumBytes - lbyteCount) < lbuffSize) Then
        lbuffSize = lnumBytes - lbyteCount
    End If

    Dim ldata As Byte() = New Byte(lbuffSize - 1) {}
    lstream.Read(ldata, 0, lbuffSize)

    luploadStatus = lbi.UploadFile(luploadStatus.UploadID, Nothing, ldata)
    lbyteCount += lbuffSize
End While

Dim linfoobjects As New BusinessObjects.DSWS.BIPlatform.Desktop.InfoObjects
linfoobjects.InfoObject = {lfileInfoObject}
luploadStatus = lbi.FinishUploadWithObject(luploadStatus.UploadID, lfilename, linfoobjects, Nothing)
Share
10 |10000 characters needed characters left characters exceeded
Karthik Kanniyappan
Nov 10, 2016 at 05:26 AM
1

Hi Thilo, I suggest you can consume the RESTful web service which is already available starting BI 4.2 SP2 . RESTful web sevices which are available are easier to consume and you can upload not just BOE documents but including agnostic documents . A simple RESTful call for uploading your document would look like this :

Use POST:

RESTful Service URL : http://<baseURL>/infostore/folder/<folder_id>/file

Replace <baseURL> with the base URL for RESTful web service requests.

Replace <folder_id> with the SI_ID of the folder in which you want to upload a file.

Add the logon token information in the Header as X-SAP-LogonToken

Add the form-data for your file you want to upload(From your client, u can browse for the file and select which file to upload)

and upload by sending the request .

You can upload any BOE (Webi, Crystal and Lumira documents) or Non-BOE documents (Any Agnostic documents like Word Document, Adobe Acrobat and Text)

Share
10 |10000 characters needed characters left characters exceeded
Vinay Hegde
Nov 10, 2016 at 05:36 AM
0

Thanks Karthik.

Share
10 |10000 characters needed characters left characters exceeded