Simplifying Web Service Integration 
by Neal Culiner

Listing One

<WebMethod(), SoapRpcMethod()> _
Public Function HelloWorld(ByVal p As String) As String
    If p.ToLower = "test" Then
        Return "Hello World"
    Else
        Return "Invalid Parameter"
    End If
End Function


Listing Two

Public Function HasUpdates() As Boolean
    On Error GoTo Err_Updates
    Screen.MousePointer = 11
    SOAP1.reset
    SOAP1.ValueFormat = vfText
    SOAP1.MethodURI = "http://webservices.nc-software.com/UpdateService"
    SOAP1.ActionURI = "http://webservices.nc-
                              software.com/UpdateService/GetUpdateByMajMinRev"
    SOAP1.URL = "http://webservices.nc-software.com/20/UpdateService/UpdateService.asmx"
    SOAP1.method = "GetUpdateByMajMinRev"
    SOAP1.AddParam "XMLProductCode", XMLProductCode
    SOAP1.AddParam "iMajor", APP.Major
    SOAP1.AddParam "iMinor", APP.Minor
    SOAP1.AddParam "iRevision", APP.Revision
    SOAP1.AddParam "p", "mypassword"
    SOAP1.SendRequest
    
    Dim strReturn As String
    strReturn = SOAP1.returnValue

    If Trim$(strReturn) = "" Then
        HasUpdates = False
        Screen.MousePointer = vbDefault
        Exit Function
    End If
    
    If InStr(strReturn, "|") > 0 Then
        HasUpdates = True
        Dim arr As Variant
        arr = Split(strReturn, "|")
        With ncUpdateInfo
            .UpdateTitle = arr(0)
            .BriefDescription = arr(1)
            .DetailedDescription = arr(2)
            .DownloadURL = arr(3)
            .InfoURL = arr(4)
            .DownloadSize = arr(5)
            .IsCritical = CBool(arr(6))
        End With
    Else
        HasUpdates = False
    End If
        Screen.MousePointer = vbDefault
Exit Function

Err_Updates:
    HasUpdates = False
    Screen.MousePointer = vbDefault
End Function


Listing Three

Private Sub DoDownload()
    On Error GoTo Err_Download
    Screen.MousePointer = 11

    If Dir(updateFile) <> "" Then
        FileSystem.Kill updateFile
    End If
    
    With HTTP1
        .LocalFile = updateFile

        .Get ncUpdateInfo.DownloadURL
    End With
    Exit Sub

Err_Download:
    Screen.MousePointer = vbDefault
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, _
                             UnloadMode As Integer)
    HTTP1.Interrupt
End Sub

Private Sub HTTP1_Disconnected(StatusCode As Integer, _
                               Description As String)
    If StatusCode <> 0 Then
        If Dir(updateFile) <> "" Then
            FileSystem.Kill updateFile
        End If
    End If
    EnableButtons
End Sub

Private Sub HTTP1_EndTransfer(Direction As Integer)
    Me.cmd(1).Caption = "&Update Now"
    Me.cmd(2).Caption = "&Close"
    Me.cmd(1).ToolTipText = "Click to begin the update and close Logbook Pro"
    Me.progBar.Visible = False
    Screen.MousePointer = vbDefault
    EnableButtons
End Sub

Private Sub HTTP1_Error(ErrorCode As Integer, _
                        Description As String)
    If Dir(updateFile) <> "" Then
        FileSystem.Kill updateFile
    End If
    EnableButtons
End Sub

Private Sub HTTP1_Header(Field As String, _
                         Value As String)
    On Error Resume Next
    If UCase(Field) = "CONTENT-LENGTH" Then
        lngFileSize = CLng(Value)
    End If
End Sub

Private Sub HTTP1_StartTransfer(Direction As Integer)
    DisableButtons
    Me.progBar.Visible = True
    Me.progBar.FloodPercent = 0
End Sub

Private Sub HTTP1_Transfer(Direction As Integer, _
                           BytesTransferred As Long, _
                           Text As String)
    Me.progBar.FloodPercent = (BytesTransferred / lngFileSize) * 100
End Sub


Listing Four

With XMLp1
        .Input strXML
        .XPath = "/dsLogbook"
        Dim I As Integer
        Dim j As Integer

        For I = 1 To .XChildren
            .XPath = "/dsLogbook/[" & I & "]"
            Select Case .XElement
                Case "PDACertificates"
                    Set rst = mydb.OpenRecordset("PDACertificates", dbOpenDynaset)
                    rst.AddNew
                    rst.Fields("CertificateID").Value = .Attr("CertificateID")
                    rst.Fields("Grade").Value = .Attr("Grade")
                    rst.Fields("Number").Value = .Attr("Number")
                    rst.Fields("DateIssue").Value = GetPPCDate(.Attr("DateIssue"))
                    rst.Fields("Remarks").Value = .Attr("Remarks")
                    rst.Update
                    rst.Close
                    Set rst = Nothing
               End Select
        Next
    End With



3


