Upload Web Service - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

The URL for the web service that contains all the methods is http://localhost/spfserver/Upload.asmx

Used to send collections of data to SmartPlant Foundation and invoke the load mechanism to validate and persist in the database. Currently, SmartPlant Foundation has two loading mechanisms. One uses streaming technology and is designed to consume less memory and be faster – the input for this is schema style XML. The other, the traditional loader, runs through the rich core, allowing customization/overrides and subscription. This can accept input in the schema style XML and also the legacy NLF format. Typically, large files should be loaded using the streaming loader that requires schema style xml.

Therefore, two web methods are supported:

  • One that accepts a relative file containing XML

  • One that accepts a transfer object containing items to load that are converted into NLF format.

Example code below shows calls to each web method from the client.

Dim lobjUploadResult As UploadService.XFRUploadResult

Dim lobjTransfer As UploadService.XFRDataTransfer = GetXFRDataTransfer(txtFilename.Text)

If lobjTransfer Is Nothing Then

lobjUploadResult = lobjUploadService.UploadFileValidateOpt(lblSessionId.Text, lstrFileNameWOutPath, chkSkipValidation.Checked, chkAttachSourceFile.Checked)

Else

lobjUploadResult = lobjUploadService.UploadTransfer(lblSessionId.Text, lobjTransfer, chkAttachSourceFile.Checked)

End If

txtRequestID.Text = lobjUploadResult.RequestID

Each web method creates an upload request object in the database and optionally relates the source file to it. Then the actual load is done by an async web method in the background, and the OBID of the request object is returned back to the calling client.

Output from the UploadData web method is in the form of a XFRUploadResult as shown below. The UploadHasBeenProcessed node is False initially until the load completes.

<XFRUploadResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <XFRRequestID>OBIDOFUPLOADREQUEST</XFRRequestID>

  <XFRUploadHasBeenProcessed>True</XFRUploadHasBeenProcessed>

  </XFRUploadResult>

Any errors encountered during load are written to the output file that is then attached to the upload request object when the load finishes. There are web methods to check and verify if the data load has finished and then return the OBID of the output file to be viewed.

GetUploadResultLog is generally the first call passing in the UploadRequest OBID. This returns an indicator stating whether the load has been processed or not (RequestHasBeenProcessed). If it has been processed, it returns the OBID of the log file.

ViewFileUsingVirtualFilePath can then be called using the output file OBID that returns the URL to the file in the view directory.