AddWorkOrder Sample - HxGN EAM - 12.0.1 - Customization & Programming - Hexagon

HxGN EAM Web Services Toolkit Programmer

Language
English
Product
HxGN EAM
Search by Category
Customization & Programming
HxGN EAM Version
12.0.1

The AddWorkOrder sample application demonstrates how to import a WSDL file that describes an HxGN web service, howA to call an HxGN web service, and how to use the results of that call. The web service that is used in the sample is AddWorkOrder (Function #MP0023). This web service is described in the MP0023_AddWorkOrder_001.wsdl file.

After creating a project in Visual Studio, add a web reference to the desired WSDL files. See Adding a service reference to a WSDL file.

Once the WSDL file has been added to the project, you will have access to various classes in the WebServices.MP0023 namespace. The first class of interest is AddWorkOrderService. This class contains properties used to construct the SOAP header, as well as the methods needed to call the service. MP0023_AddWorkOrder_001 and MP0023_AddWorkOrder_001_Result are also particularly important. The former is used to provide the data required by the web service, while the latter is where the web service will return information to the caller.

The sample's primary form (AddWorkOrderForm) contains input fields to gather all the information needed to add a work order.

After entering the information, the user would click Submit to trigger the call to the web service. The Submit button's click event handler calls the CallAddWorkOrderService routine, which will set up and call the web service. The routine performs the following steps:

  • Calls the AreAllRequiredFieldsFilled routine to validate that all fields have been entered.

  • If empty required fields are found, the code attempts to set focus to the offending control.

  • Prompts for the login details.

  • Defines variables needed to call the web service.

  • A reference to the actual web service class:

    Dim addWOService As WebServices.MP0023.AddWorkOrderService

    An instance class that will hold the information that must be passed to the web service call:

    Dim serviceData As New WebServices.MP0023.MP0023_AddWorkOrder_001

    A reference to the class that will hold the result of the call to the web service:

    Dim result As WebServices.MP0023.MP0023_AddWorkOrder_001_Result

  • Calls the InitializeWOService routine and assigns the result to the addWOService variable. This routine is broken down later in this chapter.

  • The serviceData object has a property WorkOrder that will contain the information that was gathered on the form. This property is set by a call to the CreateWorkOrder routine. This routine is broken down later in this chapter.

  • Calls the AddWorkOrderOp method of the web service instance. This is the routine that was generated from the WSDL file and is the actual call to the web service.

    Always make the call to a web service in a Try/Catch block, since any problems will be raised by the web service as a SoapException.

  • Assigns the result to the Result variable. The work order number is returned in the "result.ResultData.JOBNUM" property.

    result = addWOService.AddWorkOrderOp(serviceData)

    Before accessing the result variable and its properties, it must be tested to ensure that it is not set to Nothing (null). This may occur if the web service call returns an invalid or corrupt response. Also note that the web service call may still have been successful in this case.