Hello,
I am trying to invoke a SOAP Web Service Asynchronously. I have added a handler to my code, but it is never invoked after the SOAP process has finished. Below is my code.
The Web Service is loaded and executes without issues. Upon completion, my handler is not invoked. Am I adding the Handler in the right place? Am I invoking the handler properly?
I've been struggling with this one. Any help provided will be greatly appreciated.
Regards,
Matt Paisley
Public Class DueDilligence
Public handlerAttached As Boolean = False
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button4.Click
Dim success As Boolean, strSuccess As String
Dim b As Button = DirectCast(sender, Button)
Try
Select Case b.Name
Case "Button1"
Case "Button4"
strSuccess = KycCustomerCheck()
If strSuccess = "Success" Then
txtSessionId.Text = "Processing Request"
Else
txtSessionId.Text = strSuccess
End If
End Select
Catch ex As Exception
txtSessionId.Text = "ERROR: " & ex.Message
End Try
End Sub
Private Function KycCustomerCheck() As String
If Not handlerAttached Then
AddHandler My.WebServices.CustomerDueDilligenceService.CustomerDueDilligenceCompleted,
AddressOf Me.getCDDresults
handlerAttached = True
End If
Dim KYC As New CustomerDueDilligence.CustomerDueDilligenceService()
Dim BPCredentialName As String = My.Settings.BPCredentialName
Dim BPResourceName As String = My.Settings.BPResourceName
Try
KYC.Url = My.Settings.HostName & My.Settings.PortAssignment & "/ws/CustomerDueDilligence"
KYC.Credentials = New System.Net.NetworkCredential(My.Settings.uid, My.Settings.pw)
KYC.CustomerDueDilligenceAsync(txtFirstName.Text, txtLastName.Text,
txtFirstName.Text & " " & txtLastName.Text,
txtStreet.Text, txtCity.Text, txtState.Text, txtZipCode.Text)
Return "Success"
Catch ex As Exception
Return "Exception - " & ex.Message
End Try
End Function
Private Sub getCDDresults(ByVal sender As Object, ByVal results As CustomerDueDilligence.CustomerDueDilligenceCompletedEventArgs)
txtSessionId.Text = "Completed"
End Sub
End Class