Abstract: This article describes in detail how to develop Web Services-based applications in Delphi by using Delphi and Web services. Keywords: Delphi; web service; SMS Application Development When talking about application development based on Web Services technology, the development tool that most people first think of is vs.net. In fact, as the leader of fast application development tools (RAD, delphi has supported the development and application of Web Services since 6.0, this document describes how to develop a Web Services-based application system in Delphi by using Delphi 7.0 to call the Web Service sent by Sina SMS. Step 1: Prepare for the Sina text message web service. The Web service address sent by Sina is http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl. the Web Service has only one method, namely string sendxml (carrier, userid, password, mobilenumber, content, msgtype ). All parameters are of the string type. Their meanings are as follows (which may be incorrect ). Carrier: Carrier name. It seems that you can enter "Sina" at will. If you enter other values, the message sending speed is very slow; Userid: your mobile phone ID registered on Sina wireless, if you have not registered your mobile phone on the http://sms.sina.com.cn, you can not use this web service to send text messages; Password: the password you used when registering your mobile phone on Sina wireless; Mobilenumber: the mobile phone number of the other party; Content: The content of the short message; Msgtype: the type of short message to be sent. I estimate that MMS is supported, but I don't know how to use it. It seems that I can enter anything at will. I use "text ". For more information about the billing standard, see the description on the Sina wireless website. It may be a dime, but it may also be a two-way license. It is not clear. Because the background may use the message queue mechanism, there may be a long delay during busy hours. Step 2: Create a blank application. Run Delphi 7 and open the [file]-> [new]-> [application] menu. Delphi automatically generates a default project. Change the default form form1 to SMS, and save the project as smsdemo. prj. As shown in: Figure 1 Step 3: introduce web service ., Open the [file]-> [new]-> [other] menu, select the WebServices tab page in the pop-up window, and then select the WSDL importer option, click OK to bring up the WSDL importer wizard window, as shown in figure 2. Enter the http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl in the location of WSDL file or URL on it (note, do not enter the error !), Click the next button, and then click finishi to complete the introduction of the SMS web service. In this case, a file named smswebservice0101.pas will be added to the project file. This is an automatic web service import declarative file generated by Delphi. Do not modify it manually. Figure 2 Step 4: Call the SMS sending interface of web service. In the SMS form, four tedit controls, one tbutton control, one tmemo control, and five tlabel controls are added in sequence, which are arranged and set in figure 3. Figure 3 The uses statement of the smsfrm unit contains smswebservice0101, so that the form can access the Web Service Interface sent by Sina. Write the following code in The onclick event of the send button: Procedure TSMS. button1click (Sender: tobject ); Begin Memo1.text: = getsmswebservicesoapport. sendxml (edit1.text, Edit2.text, edit3.text, edit4.text, edit5.text, ''text ''); End; Note: edit1, edit2, edit3, edit4, and edit5 correspond to the operator, user name, password, peer number, and message content on the Interface respectively. Feedback on the Interface corresponding to memo1. Step 5: use the Web Service short message sending interface to send short messages. Compile and run smsdemo. prj: enter your mobile phone ID and password registered on Sina wireless in the user name, enter your password on Sina wireless, and then enter the recipient's mobile phone number and message content, click the send button. After a moment, the Web Service feedback will be displayed in the feedback box. If everything is normal, the system will prompt you that the text message is sent successfully. Summary From the above example, we can see that as long as you understand the concept of Web Services, it is not very difficult to develop Web Services-based applications with the help of Delphi. Web services is most suitable for developing cross-platform and cross-network communications (because HTTP is allowed by the firewall) programs, which can span heterogeneous architectures, contacting customers, suppliers, business partners, and internal information systems is the best solution for integrating B2B e-commerce and enterprise information. Every company needs to expose the business logic and become a web service, so that any designated partner can call the business logic, regardless of the platform on which their system runs, development tools used. Web services is a very popular and rapidly developing technology. This article is just a little bit of learning experience by the author. You are welcome to correct it. (Full text) Note: I am grateful for the Sina messaging Web Service technology in http://blog.joycode.com/joy/posts/16939.aspx. Showwindow. Unit System VaR cmdshow: integer; Description In the program, when the application creates the main window, the cmdshow variable contains the parameter values that Windows wants to pass to showwindow. In the library (DLL), cmdshow is always 0. 3. compilerversion constant Indicates the version number of the Delphi compiler. Unit System Const compilerversion = 15.0; Description You can use compilerversion to test the configuration level of the Delphi compiler. If you want to conditional update the special code using the Delphi language, this will be very useful (this is useful if you want to conditionalize code that takes advantage of newer features in the Delphi language ). 4. exitprocessproc variable Exitprocessproc specifies the process (Procedure) That is last executed before the application is shut down (shut down ). Unit System VaR exitprocessproc: procedure; Description Assign the value to exitprocessproc to specify the process you want to execute before the application is closed. The value of exitprocessproc is a process without parameters. 5. getfileversion Function Returns the file version. Unit Sysutils Function getfileversion (const afilename: string): Cardinal; Description Getfileversion returns the most meaningful 32-bit binary version of a file. Afilename specifies the file name, which can be searched using the same path as the loadlibrary function. 6. getmodulename Function Returns the fully qualified name (fully qualified name) of the module for the given handle ). Unit Sysutils Function getmodulename (module: hmodule): string; Description Call getmodulefilename to obtain the fully qualified name of the module with the given handle. Module is the module handle. 7. hinstance variable Handle, which is provided to the module by windows ). Unit Sysinit VaR hinstance: longword; Description Hinstance contains the instance handle of applications or libraries provided by Windows 8. hintwindowclass variable Class used to display the help hint window. Unit Forms VaR hintwindowclass: thintwindowclass = thintwindow; Description When the application displays the help hint, it creates an hintwindowclass instance to depict the window for displaying the prompt. The application creates a thintwindow derived class and then assigns the derived class to the hintwindowclass variable when the application starts. This window can be customized. 9. initproc variable Initproc is the last installation initialization process. Unit System VaR initproc: pointer; Description Assign a value to initproc to specify the process you want to execute when the application starts. Initproc is a non-parameter process. For example: Procedure myinitprocedure; ... Initialization Initproc: = @ myinitprocedure; Begin End; Only one initialization process can be assigned an initproc variable. If your application defines multiple initialization processes, only the last one that is assigned to initproc will be executed. To allow execution of other initialization processes, you must "Link" the process and call the original value from the new value of initproc. For example, the following code from the comobj unit saves the original value of initproc before the new value is assigned, and then calls and saves the value in the new initialization process: Saveinitproc: = initproc; Initproc: = @ initcomobj; 10. isconsole variable Indicates whether the module is compiled as a console application. Unit System VaR isconsole: Boolean; Description If the module is compiled as a console application, the isconsole variable is true. This will be true in both the executable file and DLL ). 11. islibrary Variables Indicates whether the module is a DLL. Unit System VaR islibrary: Boolean; Description If the module is a DLL, The islibrary variable is true. 12. jitenable variable Controls when the scheduler is called in time (controls when the just-in-time debugger is called ). Unit System VaR jitenable: byte = 0; Description Use jitenable to indicate which types of exceptions will trigger the timely debugger. When jitenable is 0 (default), all exceptions are handled by the Exception Handling Mechanism of the application. The timely debugger is called only when the application does not provide any mechanism to capture exceptions. Note: Except for the initialization and termination areas in the Delphi unit, any application that contains the forms Unit provides Exception Handling (through the Application object ), does not trigger the timely debugger (note that any application that has des the forms Unit provides Exception Handling (via the application object) for all but the initialization and finalization sections and does not trigger the just-in-time debugger ). When jitenable is 1, any non-native exceptions (exceptions caused by Code Compiled using other products ). Will trigger the timely debugger. Native exceptions are handled by the Exception Handling Mechanism of the application. When jitenable is greater than 1, all exceptions will trigger the timely debugger. Note: When you install IDE, it will be registered as a timely debugger. If you have installed other tools with debuggers, they may have registered themselves and covered ide registration. 13. Ages Functions List the locale for which support is available ). Unit Sysutils Function languages ages: tlanguages; Description You can use the value returned by ages to obtain region information supported by the system. This function is only available on Windows. 14. maininstance variable Instance handle that indicates the main executable files. Unit System VaR maininstance: longword; Description Use maininstance to obtain the instance handle of the main executable files in an application. In applications that use runtime libraries or packages, this is useful when you need executable files instead of library handles. Note: Do not use maininstance when running a clx dynamic link library (Windows) or shared object (Linux) from an executable file compiled with other tools. 15. mainthreadid variable Indicates the main execution thread in the current module. Unit System VaR mainthreadid: longword; Description Use mainthreadid to obtain the thread ID of the main execution thread (the current thread at module initialization. During debugging, the main thread ID is displayed in the thread status box. In Windows, the value of mainthreadid is compatible with the thread ID required for some WIN32API calls. 16. noerrmsg variable Determines whether the application displays an error message when a running error occurs. Unit System VaR noerrmsg: Boolean = false; Description In Windows, set noerrmsg to control whether a message is displayed to indicate that a runtime error has occurred. When noerrmsg is false (default value), a runtime error will cause the application to display a message box to indicate the type of the error. When noerrmsg is true, these messages are forbidden. In Linux, noerrmsg has no effect. Note: The sysutils unit converts most runtime errors into exceptions. If your application contains sysutils, even if noerrmsg is false, the runtime error message box may not be displayed. 17. popuplist variable Provides centralized processing for Windows messages in the pop-up menu (popup menu ). Unit Menus VaR popuplist: tpopuplist; Description You can use popuplist to access all the pop-up menus in the application or the window handle for accessing the response pop-up menu message. Popuplist maintains the list of all pop-up menu components created in the application. This list stores a handle for a hidden window that centrally processes Windows messages sent to these pop-up menus. 18. rtlversion constant Indicates the version number of the Delphi runtime database. Unit System Const rtlversion = 15.0; Description You can use rtlversion to check the version number of the Delphi Runtime library that is not dependent on the compiler version. 19. Screen variable Display a screen device Unit Forms VaR screen: tscreen; Description The screen variable is a tscreen component that represents the screen of the system in which the application is running. By default, an application creates a screen component based on information about the current screen device and assigns it to the screen variable. 20. win32platform variable The identifier of the Win32 platform. Unit Sysutils VaR win32platform: integer = 0; Description Win32platform is used to identify the type of Win32 platform in which the system runs. This will be one of the following values: Value Meaning Ver_platform_win32s system is Win32 Ver_platform_win32_windows is Windows 95 Ver_platform_wn32_nt is Windows NT Win32platform is only available on Windows. |