With the development of Internet / intranet, the development model has changed. The first wave of important technologies is http / html, and he brings an important influence on Internet / Intranet and e-commerce. The second wave is the rise of Java technology, Java Bringing a shuttle machine, let developers can use a single language and environmental development application system; the third wave is the rise of XML technology, which provides a standard data package, allowing data exchange across a variety of platforms, Operating systems and various tools, through XML, various data exchange no longer headache.
The concept of webservice is to use a standard output interface to define the functionality provided by the code so that the outside world can be called through this standard output interface, and the so-called standard output interface is WSDL, WSDL is an XML composed file, describing the implementation The procedure provides the prototype of the function, and the client can call the service code provided by the program via WSDL. Here I don't want to introduce the principles and concepts of WebService in detail, to show new network-based development modes through an example.
In this example, the server is done by Java, the client is done by Delphi, the development tool is JBuilder9 and Delphi7, and the server is Tomcat 5.0.
First establish a server program:
Start JBuilder to establish a project, set the server to Tomcat 4.0 (because JBuilder9 does not support Tomcat5.0, which is implemented in Tomcat 5.0).
New Class code is as follows:
Public class helloworld {
Public String Sayhello () {
Return "Hello World!";
}
Public String Echo (String U) {
Return "Hello" U;
}
}
Select the File menu NEW, select Web Services Configuration Wizard in the pop-up dialog box, create a new WebApp Axis and configure servers.
Select the File menu again, select the Export AS a Web Service Wizard in the window appear again, select the class name you want to export in the pop-up, other items to select the default value.
Run the program that has just established, the page of "JBuilder Apache Axis Admin Console" said that the WebService just established. Click the View hyperlink to enter the And Now ... Some Services page, click the WSDL descriptor file to click the HelloWorld (WSDL) link, to this WebService server is completed.
Publish the WebService just created into Tomcat5.0, create a new WebServiceTest directory in Tomcat's WebApps directory, will copy all of the files under the AXIS directory under the project directory established by JBulider to restart Tomcat, access http: // LocalHost: 8080 / WebServiceTest /, if you see the "JBuilder Apache Axis Admin Console" page description is released.
Start Delphi7 new project, then select New WebServices in the WSDL IMPORTER wizard, import the WebService description file WSDL (my address is: http: // localhost: 8080 / webservicetest / service / helloworld? WSDL) Automatically generate a unit HelloWorld1, using unit helloworld1 in Unit1, put two Button on the form, write the following test code in the Click event of Button1: Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
VAR
Test: helloworld;
Str: string;
Begin
Test: = GetHelloWorld; (get a remote interface provided by WebService)
Str: = Test.SAYHELLO;
ShowMessage (STR);
Test: = NIL;
END;
Run the test program, pop up "Hello, World" instructions successfully. Button's test code is similar, I am no longer repeated here.
At this point, a completed WebService program is completed and can run smoothly.