CSharp
Back to Phone Notify!
Consuming a Web Service with C#
We will use Phone Notify! for this example. All of the other Web Services 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:
cnotify.PhoneNotify pn = new cnotify.PhoneNotify(); cnotify.NotifyReturn nr = pn.NotifyPhoneBasic("8005524444", "Hello, this is a test.", "8005422323", "Test ID", "4", "0");
That is all there is to sending a notify via C#. The object nr will have a QueueID in it. You can use the method GetQueueIDStatus to watch the call as it progresses.
Phone Notify Advanced
Be sure to use a WebReference for Phone Notify Advanced.
Put the WSDL that you wish to consume in the URL block. (ex: http://ws.cdyne.com/notifyws/phonenotify.asmx?wsdl)
In order to consume a WebReference in Visual Studio 10:
1. Right click on references
2. Click add Service reference
3. In the lower left hand side click Advanced
4. Choose add WebReference
Notify.PhoneNotify pn = new Notify.PhoneNotify(); Notify.AdvancedNotifyRequest anr = new Notify.AdvancedNotifyRequest(); anr.CallerIDName = "CDYNE"; anr.CallerIDNumber = "1234567890"; anr.PhoneNumberToDial = "5555555555"; anr.TextToSay = "Hello, this is a test."; anr.LicenseKey = "License Key"; anr.VoiceID = 1; anr.UTCScheduledDateTime = DateTime.UtcNow; Notify.NotifyReturn response = pn.NotifyPhoneAdvanced(anr);
