Delphi6 preemptive research: WebServicesoap version of Hello World

zhaozj2021-02-08  245

The SOAP technology claims Microsoft Dream, but also the biggest selling point for Borland to Delphi 6, but unfortunately, it has not been able to understand, although he met at the Delphi 6 Shanghai Conference on June 14 (see "Delphi 6 Shanghai Conference") But because I have never been exposed until Delphi 6 is about to launch her new feature before I know that there is SOAP, and I have never known that the so-called SOAP is a stuff before June 14th. Delphi 6 Help and too unharequently, only the two demo is too complicated, and it is not based on HTTP, I have to study it, I have a big breakthrough, so I will share it with everyone: Given the Delphi6 Demo is too complicated, I will write a simple helloworld with Windows98 PWS: server: 1.New|Webservices|SoapserVerapplication, choose ISAPI (if you want to try Delphi6 new Web App debbuger, you can also choose It, about it, I want to say another further); 2. SaveAll, Unit1 named: mainwm, project1 named: SOAPTEST; 3. Add: InvokeRegistry4. Customize an interface, and its corresponding class implementation: ISoapHello = Interface (IInvokable) [ '{6DF34980-6FFC-11D5-9E62-0050BABD8FE1}'] // this GUID you use Ctrl Shift G generates Function getHello (aID: Integer): WideString; StdCall; End; TSoapHello = class (TInvokableClass, ISoapHello) Protected function getHello (aID: Integer): WideString; StdCall; End; 5 getHello functions implemented:. function TSoapHello.GetHello (aID: Integer): WideString; Begin If (aID = 1) Then Result: = 'Hello World!' Else Result: = 'Error ID!'; End; 6 registration interfaces and classes:. Initialization InvRegistry.RegisterInterface (TypeInfo (ISoapHello)); InvRegistry.RegisterInvokableClass (TSoapHello); 7 compiler can generate the:. SoapTest.dll start PWS, Set the virtual directory SOAP to the directory where the SOAPTEST.DLL is located, permission is to perform open IE, enter the URL to see a table to see a table, showing this SOAP service (that is, the so-called Web service) The WSDL provided in which we should have a custom interface: IsoapHello point this link will return an XML document client:

1.New|application2.saveAll, Unit1 named clnmain, project1 named soapclient3.new|webservices|WebServicesImporter, enter: http://localhost/soap/isoaptest.dll/wsdl/isoaptest.dll/wsdl/isoaptel, if you look at IE That's right, then you will produce a unit, where we have interface 4.saveall defined at the server 4. SaveAll, unit1 named soapintf, then add SOAPINTF5 in CLNMain. Put Edit, Label, Button on Form1. HTTPRIO (the first one in the web services page), set httprio1.url: http://localhost/delphi6/soap/soaptest.dll/soap6. Double-click Button1 Enter the following program: Var P: isoaphello; Begin P: = httprio1 as isoaphello; label1.caption: = p.GetHello (strt "); end; 7. Compile operation, enter" 1 "in Edit1, press Button1, Label1 will display" Hello World! " Enter other numbers will display "Error ID!" Soap so easy. ^ _ ^ I homepage on this article http://gental.top263.net/Mentals/tech/delphi/d6_soap1.htm

转载请注明原文地址:https://www.9cbs.com/read-2650.html

New Post(0)