Calling Server APIs - 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

If your customization spans both client and server and you have written your own Server API, then you will need to call it from your client code.

There is a method on the SPFSession class called CreateRequest, where you pass in the name of the Server API you want to call and you will be given a ServerRequest object. You can then add additional information into the server request by using the AddQueryProperty method(s).

Public Sub AddQueryElement(ByVal pstrXMLName As String, ByVal pstrValue As String)

Public Sub AddQueryElement(ByVal pnodXMLNode As XmlNode)

Above are the AddQueryElement properties, normally the first one is the return xml from other functions like IObject.GetObjectNode or IObjectDictionary.GetObjectNodes. The second overloaded method is useful for adding additional xml elements.

Then execute the query by calling the .Execute method.

Dim lobjRequest As ServerRequest = SPFWindowsFormsClient.SPFSession.CreateRequest("MyCustomServerAPI")

lobjRequest.AddQueryElement(pobjBaseObj.GetObjectNode())

lobjRequest.AddQueryElement("RetainHistory", pstrRetainHistory)

lobjRequest.Execute()

'

' Was there any failures

'

If lobjRequest.HasFailures Then

ExceptionDialog.ShowException(lobjServerReq.GetFailureExceptions, SPFWindowsFormsClient.MainForm.SPFWindowsFormsClient, "", True, 7229)

End If

Return lobjRequest.Response

You can check to see if there are any failures by looking at the HasFailures property and if so access the exceptions using the GetFailureException or GetFailureExceptions.

There is a method called GetItems that can be used to extract items from the returned xml and place into a collection. It is overloaded so you can pass in your own XPath and/or container you want the items to be placed in. The default XPath is Reply/Container.

The XML sent back can also be accessed using the Response property.