|
Comments
|
Today's Top SOA Links
Sybase Unwired Platform Personalizing Your PowerBuilder Applications Using SMS and Voice Messaging
Open up a window of possibilities
By: Deanne M. Chance
Apr. 14, 2007 04:15 PM
Text messaging is cool. Voice messaging is even cooler. Wouldn't it be great to be able to add that functionality to your PowerBuilder apps as well? For example, when an event occurs within your application, let your users receive real-time notification via SMS or voice messaging to their cell phones! This article will focus on writing Web services to do just that using the Strike Iron SMS and PhoneNotify messaging services. Download the print PDF of this article
Reflection The first thing you'll want to do is to include the necessary SOAP support in your project. This is encapsulated in a PBD called pbwsclient105.pbd and is located in your .../PowerBuilder/Shared directory. Add it to your project as shown in Figure 2. [Editor's Note: PowerBuilder 10.5 also allows you to import the PBNI objects from the PBX/DLL file directly into a PBL rather that using a separate PBD.] The next thing you will want to do is create a Web service proxy. The easiest way to do this is to access the Web Service Proxy Wizard. You can find it by choosing File->New and choosing the project tab (see Figure 3). The first thing the wizard will ask you is whether you want to use the .NET engine (see Figure 4). You should check the box indication yes. In case you're wondering, the alternative is to use the EasySOAP implementation of Web services. This is the precursor to the current incarnation and is no longer being developed nor does it support custom headers. Unless you have some kind of backward compatibility issues, you would want to use the newer .NET engine. Next, specify the WSDL location (Web Services Description Language) that will bring in the functions and structures needed to call the Web services you are interested in (see Figure 5). Finally, when you have finished the wizard, you'll need to deploy your proxy. You can do this by going to Design->Deploy Project while the proxy definition is open in the painter (see Figure 6). You are now ready to call your Web services. Calling a Web service is fairly straightforward. There is just a little setup work to do before the actual call. Namely, you'll need to add script similar to this. Of course, you will want to substitute in your own proxy names but the setup is the same. //phone notify service Example Usage PhoneNotify Voice Messaging Service Sample Code The Strike Iron Text Message Service Sample Code lws_textmsgservice.SendMessage(ls_ToNumber, ls_FromNumber, ls_FromName, ls_Text) Also easy; however, what I have glossed over and will now revisit is the authentication method. In this case, the authentication is sent in the SOAP header (see Listing 2). Why do that? SOAP headers offer a method for passing data to and from an XML Web service method if the data is not directly related to the XML Web service method's primary functionality. For instance, an XML Web service might contain several XML Web service methods, each requiring a custom authentication scheme. Instead of adding parameters to each XML Web service method for the custom authentication scheme via a customer SoapHeader, it can be applied to each XML Web service method. This is the case with the Strike Iron SMS Web service. [Editor's Note: See the SoapHeader class reference in the References section below for the values to pass for the various attributes that PowerBuilder does not automatically set default values for.] The question is, when did PowerBuilder start supporting this functionality and how can you use it. The answer is 10.5.1 and the specifics are best answered by reading "what's new" in the help file. Specifically, you would want to look for "Custom header support for .NET Web services." One word of caution though, you must populate every attribute in your set functions structure. If you don't, the set function will fail, the SOAP header will not be sent, and you may spend hours asking yourself why. I know because I learned this the hard way. Conclusion Happy coding!
Reader Feedback: Page 1 of 1
Your Feedback
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
|||||||||||||||||||||||||||||||||