DELPHI6 preemptive Research: Hello world for WebService/soap

Source: Internet
Author: User

 

The soap technology is known as the Microsoft dream and the biggest selling point Borland has set for Delphi 6. Unfortunately, it has never been figured out, although I have seen it at the June 14 Conference in Delphi 6 Shanghai (see "Delphi 6 Shanghai Conference"), I have never touched it before, it was not until she saw her new feature before the release of Delphi 6 that she knew about soap, and she had never known what the so-called soap was before June 14, the help of Delphi 6 was not detailed. The only two demos were too complicated and not based on HTTP. I had to study them myself. In the last two days, there was a major breakthrough, so here we will share with you:
In view of the complexity of the demo provided by DELPHI6, I will write a simple helloworld here, which is implemented using Windows98 + PWS:
Server:
1. New Taobao WebServices release soapserverapplication, select ISAPI (if you want to try the new web app debbuger in DELPHI6, you can also choose it. I want to talk about it again );
2. saveall, unit1 is named mainwm, and project1 is named soaptest;
3. Add invokeregistry to uses in mainwm.
4. customize an interface and its corresponding class implementation:
Isoaphello = interface (iinvokable)
['{6df34980-6ffc-11d5-9e62-0050babd8fe1}'] // you can use Ctrl + Shift + G to generate this GUID.
Function gethello (Aid: integer): widestring; stdcall;
End;

Tsoaphello = Class (tinvokableclass, isoaphello)
Protected
Function gethello (Aid: integer): widestring; stdcall;
End;
5. Implement the gethello function:
Function tsoaphello. gethello (Aid: integer): widestring;
Begin
If (Aid = 1) then
Result: = 'Hello world! '
Else
Result: = 'error ID! ';
End;
6. Register interfaces and classes:
Initialization
Invregistry. registerinterface (typeinfo (isoaphello ));
Invregistry. registerinvokableclass (tsoaphello );
7. compile and generate: soaptest. dll

Start PWS and set the virtual directory soap to the directory where soaptest. dll is located. The permission is to run
Open IE and enter the URL http: // localhost/soap/soaptest. dll/WSDL.
You can see a table that shows the WSDL provided by the soap Service (called Web Service ).
There should be our custom interface: isoaphello
Click its link to return an XML document

Client:
1. New login application
2. saveall, unit1 is named clnmain, and project1 is named soapclient
3. new website WebServices extends webservicesimporter. In the URL, enter http: // localhost/soap/soaptest. dll/WSDL/isoaphello. If IE is correct, a unit will be generated after confirmation, with the interface defined on the server.
4. saveall, unit1 is named soapintf, and soapintf is added to uses in clnmain.
5. put the edit, label, button, and httprio controls on form1 (the first one on the Web Services page) and set httprio1.url to http: // localhost/DELPHI6/soap/soaptest. dll/soap
6. Double-click button1 and enter the following program:
VaR
P: isoaphello;
Begin
P: = httprio1 as isoaphello;
Label1.caption: = P. gethello (strtoint (edit1.text ));
End;
7. Compile and run the program. Enter "1" in edit1 and press button1. label1 will display "Hello world! "
Enter another number to display "error ID! "

Soap so easy.
Pai_^

My home page with picture http://mental.top263.net/mentals/tech/delphi/d6_soap1.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.