APIWCFServices

The APIWCFServices endpoint provides a collective set of methods for working with TMWSuite data via a single service endpoint.

Endpoint address: [SystemsLinkRootUrl]/APIWCFServices.svc

Web Service Component Class definition

Each Component Class contains the following sub classes and properties:

Service Properties

These properties expose the database and are the properties a client uses to retrieve and update their records.

Updateable Properties

These properties define which service properties can and will be updated. The web service will only modify records in the database set to true.

Criteria Class

Defines which properties can be used as criteria to retrieve records from the database.

Return Object Class

All methods return an instance of the Return Object class. It contains the following properties:

  • Return Code: An integer that indicates if the service was successful

  • Error Messages: A list of error messages

  • Exceptions: A list of exceptions thrown by the service

  • Returned Objects: A list of return components

  • Error Object Index List: An index list that indicates which objects encountered errors during the service. These objects are the ones passed into the Save Component Methods.

  • Trace Message: A list of trace messages for the methods with implemented tracing and Trace turned on

Web Service common methods

Most Service Components have the following common methods.

New component

This method creates a component in memory (not in the database) with the object’s default values.

Return Code:

  • 0 = successful

  • 1000 = errors occurred

New components

This method creates a list of components in memory (not in the database) with the object’s default values.

Return Code:

  • 0 = successful

  • 1000 = errors occurred

Retrieve component

This method returns a list of components that meets the provided criteria. The returned component is stored within the Return Object. If a match cannot be found or the query results in an error, the default value is returned.

Return Code:

  • 0 = successful

  • 100 = no records found

  • 1000 = errors occurred

The retrieve method supports complex criteria, the example below will return any tractors with tractor number "Tractor1" or event code "LUL":

criteria.Settings = New CheckCall.CriteriaSettings()

Dim criteria1 As CheckCall.Criteria = New CheckCall.Criteria()
criteria1.Settings = New CheckCall.CriteriaSettings()

Dim criteria2 As CheckCall.Criteria = New CheckCall.Criteria()
criteria2.Settings = New CheckCall.CriteriaSettings()

criteria1.AsgnType = CheckcallAssignTypeEnum.Driver
criteria1.TractorNumber = "Tractor1"

criteria2.AsgnType = CheckcallAssignTypeEnum.Tractor
criteria2.EventCode = "LUL"

criteria.Expressions = New List(Of CheckCall.CriteriaExpression)()
criteria.Expressions.Add(New CheckCall.CriteriaExpression() With \{.Conjuction = CriteriaSetting.ConjuctionEnum.OrOp, .Criteria = criteria1})

criteria.Expressions.Add(New CheckCall.CriteriaExpression() With \{.Conjuction = CriteriaSetting.ConjuctionEnum.OrOp, .Criteria = criteria2})

Save component

This method creates new records for the passed-in components or updates existing ones in the database. The saved components are then passed back in the Return Objects list.

Return Code:

  • 0 = successful

  • 100 = validation errors occurred and updates prevented

  • 500 = update proceeded with warnings

  • 1000 = error occurred and updates prevented

If a passed-in object has errors, its index is added to the Error Object Index List in the Return Object.

In order to save a value in the database, both the service property to be updated and the corresponding property in the Updateable Properties must be changed. The service property should be updated with the value to be saved to the database and the updateable property must be set to true.

In the following example, a client is trying to save a driver’s last name to the database (Code in VB.net). If successful, the saved driver object is returned in the Reference Objects list in Return Object (retObj).

Dim svc As TMW_API_WCFServices.APIWCFServicesClient = Nothing
Dim retObj As TMW_API_WCFServices.Driver.ReturnObject = Nothing
Try
    svc = New TMW_API_WCFServices.APIWCFServicesClient()

    Dim retObj As TMW_API_WCFServices.Driver.ReturnObject = Nothing
    Dim drvList As New List(Of TMW_API_WCFServices.Driver)

    Dim drv As New SystemsLink.Driver()
    drv.IsNew = True
    drv.UpdateableProperties = New SystemsLink.Driver.DriverUpdateInfo()

    drv.LastName = "MyLastName"
    drv.UpdateableProperties.LastName = True

    drvList.Add(drv)

    retObj = svc.SaveDriver(drvList, True)

    Dim drvSaved As TMW_API_WCFServices.Driver = retObject.ReferenceObjects(0)

    Catch ex As Exception
        Throw

    Finally
        'close svc after each call
        If svc IsNot Nothing Then svc.Close()
End Try

Delete component

This method deletes a component indicated by a parameter. The deleted component is passed back in the Return Objects list.

Return Code:

  • 0 = successful

  • 100 = no records found

  • 1000 = errors occurred