Example code

<< Click to Display Table of Contents >>

Navigation:  General Functions > Configuring the MIE (Programmer's Guide) > Calling Web Services > MIEWebServices Support Module >

Example code

Example code for calling an MIE Web service (vb.net)

 

Creating an instance of the referenced web service

          Dim oWS As New com.etelligentsolutions.staging.AA

           oWS.Url = Session.AAWebURL

           oWS.Timeout = 120 * 1000       'timeout in 120 seconds

           oWS.Proxy = Nothing

 

 

Defining and initially setting the GenericCall structure

              Dim gSend As New com.etelligentsolutions.staging.GenericCall

 

               gSend.bEncrypt = True

               gSend.UserID = "<valid MIE userID>"    

               gSend.Password = oM.CRYPT("E","<valid MIE password>")

               gSend.CallingProgram = "<your program name>"

               gSend.CallingVersion = "<your program version>"

 

Creating the dataset to send the necessary parameters

              Dim dsSend As New DataSet

              Dim oM As New MIEWebServices.MIEWebServices

 

              Dim aDF(8) As MIEWebServices.MIEWebServices.FieldDefs

               oM.SetIntegerField(aDF(0), "CustNo", False)

               oM.SetIntegerField(aDF(1), "SiteNo", False)

               oM.SetIntegerField(aDF(2), "OptionNo", False)

               oM.SetIntegerField(aDF(3), "mslNo", False)

               oM.SetIntegerField(aDF(4), "AssetID", False)

               oM.SetIntegerField(aDF(5), "AssetIDxmslNo", False)

               oM.SetIntegerField(aDF(6), "ctNo", False)

               oM.SetIntegerField(aDF(7), "ctNoAuth", False)

               oM.SetIntegerField(aDF(8), "ctNoCustodian", False)

               oM.TableName = "Parameters"

               oM.FieldDefinitions = aDF

               oM.Encrypt = gSend.bEncrypt

               dsSend = oM.MakeCallingDataSet()

              Dim oVals(8) As Object

               oVals(0) = iCustNo

               oVals(1) = iSiteNo

               oVals(2) = iOptionNo

               oVals(3) = imslNo

               oVals(4) = iAssetID

               oVals(5) = iassetidxmslNo

               oVals(6) = 0

               oVals(7) = ictNoAuth

               oVals(8) = 0

               dsSend.Tables(0).Rows.Add(oVals)

               dsSend.AcceptChanges()

 

               oM.DSin = dsSend

 

               gSend.aByte = oM.ReturnCompressedDataSetXML

               dsSend.Dispose()

               dsSend = Nothing

 

Defining the GenericReturn structure and calling the web service

              Dim gRet As New com.etelligentsolutions.staging.GenericReturn

              Try

                   gRet = oWS.AnalyzeAuthorization(gSend)

              Catch ex As Exception

                   gRet.ErrorCount = 1

              End Try

 

               gSend = Nothing

 

Handling the results from the web service

              If Not gRet Is Nothing Then

                  If gRet.ErrorCount = 0 Then

                      If Not gRet.aByte Is Nothing AndAlso gRet.aByte.Length > 0 Then

                          Dim dsRet As New DataSet

                           oM.ByteIn = gRet.aByte

                           dsRet = oM.DecompressXMLDataSet

                          If Not dsRet Is Nothing AndAlso dsRet.Tables.Count > 0 AndAlso dsRet.Tables(0).Rows.Count > 0 Then

                              Dim dr As DataRow = dsRet.Tables(0).Rows(0)

                               iNewUnits = dr.Item("LUR")

                               dConf = dr.Item("ConfidenceValue")

                               sAAErrors = dr.Item("Errors")

                               sNotes = dr.Item("Notes")

                               sThreadLog = dr.Item("ThreadLog")

                               dr = Nothing

                          End If

                           dsRet.Dispose()

                           dsRet = Nothing

                      End If

                  End If

              End If