Server-side communication - SmartPlant Foundation - IM Update 48 - Help - Hexagon

SmartPlant Foundation Help

Language
English
Product
SmartPlant Foundation
Search by Category
Help
SmartPlant Foundation / SDx Version
10
SmartPlant Markup Plus Version
10.0 (2019)
Smart Review Version
2020 (15.0)

When the Desktop Client makes a request for data packaged as an XML query string and sent through a Universal Reference Location (URL) request using the SOAP protocol, the request reaches the Web active server page (ASP). The client communicates primarily with just one web method called ServerRequest. From there the server breaks down the request and directs it to the appropriate piece of code.

When the server receives the first request from any SmartPlant Foundation user, the software:

  • Loads the server assemblies named within the settings files. In each assembly, there are a number of server APIs that are stored in a cache to be referenced later when requests are made to the server for information.

  • Connects to the database.

  • Loads data into memory to improve system performance; therefore, accessing data after the initial load is considerably faster.

When the server core assembly receives a request (initially in SPFServer and then in SPFHandler), the software converts the XML into objects and stores the session information in a central context class that is accessible from any point within the server. The name of the method or server API is then read from the request, and the software makes a request to the GetServerAPI method, which returns the assembly and class that need to be executed.

The following three methods within the server API are called if they are defined:

  • OnDeSerialize - The OnDeSerialize section is used to extract any remaining part of the query that is specific to the server API from the query XML document. It converts this into a variable or object that can be used within the body of the code. If the server API has no requirement to extract any further information from the sent XML document, this section of the code may not be defined.

  • OnHandlerBody - The OnHandlerBody is then called. It opens a database transaction, if required, casts the data read in the OnDeSerialize section to the appropriate interface definition, and calls the necessary method definitions to execute the function.

  • OnSerialize - The OnSerialize section is then called to generate the XML response back to the client. This response is sometimes simply a flag set indicating the function has been successful or the response can be a complete set of data that needs to be converted into XML and sent back. For example, the data retrieved as objects from the OnHandlerBody.

The following example is a workflow describing how to execute a method definition written within the custom assembly to validate an object.

For the purposes of the illustration, the OBID of the object to be validated has been included in the XML, and the object contains a custom interface called ICustObject, which had some method definitions defined and coded for it previously.

  1. XML is delivered to the server using the SOAP protocol and is handled by the ServerRequest.asmx code.

  2. The SPFServer initiates and passes the XML into the SPFHandler. Within the SPFHandler class, session information is extracted and stored in a context object.

  3. The name of the method that needs to be executed is extracted from the XML; in this case it is ValidateObj.

  4. A call is made to the GetServerAPI function with the named method. If the custom assembly has been referenced in the settings.xml file, the function returns the assembly that contains the method.

  5. The ValidateObj server class is referenced, and the OnDeSerialize method is called. The OBID of the object is read.

  6. A call to OnHandlerBody is made, which in turn calls the GetObject function. The GetObject function returns an object. Now that the object is available, it can be cast to any interface that is associated with the object.

In the diagram the object is cast to the interface ICustObject, and the method definition ValidateObj is called. Once this function has been performed, it is validated and returns either true or false. The OnSerialize method converts this Boolean into XML, which is sent back to the SmartPlant Foundation Desktop Client.