VB.net
From CDYNE Wiki for Web Services
Back to Phone Notify!
Consuming a Webservice with VB.net
We will use Phone Notify! for this example. All of the other Webservices are just as easy to consume.
1. Open a new/existing project.
2. Right click "Add Web Reference" in the Solution Explorer on the Project you wish to add the service to.
3. Put the WSDL that you wish to consume in the URL block. (ex: http://ws.cdyne.com/notifyws/phonenotify.asmx?wsdl)
4. Change "Web Reference Name" to something more usable, like cnotify.
Use code like the following:
Dim nr As cnotify.NotifyReturn Dim pn As New cnotify.PhoneNotify ' NotifyPhoneBasic("<send to phone number>", "<text>", "<send from phone number>", "<send from text/desc.>", <voice ID>, "<license key>") ... nr = pn.NotifyPhoneBasic("8005524444", "Hello, this is a test.", "8005422323", "Test ID", 4, "0") ' OR maybe... ' the initial 3 means it will try the call 3 times before it fails... ' nr = pn.NotifyPhoneBasicWithTryCount(3, "8005524444", "Hello, this is a test.", "8005422323", "Test ID", 4, "0")
That is all there is to sending a notify via VB.Net. The object nr will have a QueueID in it. You can use the method GetQueueIDStatus to watch the call as it progresses. The code could be something like:
nr = pn.GetQueueIDStatus(nr.QueueID) lblStatus.Text = StatusCodeDesc(nr.CallAnswered, nr.CallComplete) '... Protected Function StatusCodeDesc(ByVal Answered As Boolean, ByVal Complete As Boolean) As String Dim theStatus As String = "ERROR! Values Not Defined!" If Answered = False And Complete = False Then theStatus = "The call is currently being delivered..." ElseIf Answered = True And Complete = False Then theStatus = "The call has been answered.." ElseIf Answered = True And Complete = True Then theStatus = "The call is complete!" ElseIf Answered = False And Complete = True Then theStatus = "The call is complete!" End If Return theStatus End Function
Phone Notify Advanced
Dim pn As New PN_WSDL.PhoneNotify Dim anr As New PN_WSDL.AdvancedNotifyRequest anr.CallerIDName = "CDYNE Test" anr.CallerIDNumber = "1234567890" anr.PhoneNumberToDial = "5555555555" anr.TextToSay = "This is a test. This is a test. This is a test." anr.LicenseKey = "(Your License Key)" anr.VoiceID = 1 anr.UTCScheduledDateTime = DateTime.UtcNow Dim response As NotifyReturn = pn.NotifyPhoneAdvanced(anr)
