1) download the axis package: http://ws.apache.org/axis/ first
2) The new web project name is:Axis
Copying the axis packageWebapps/axisAll files in the directory to the project directoryWebrootDirectory,
ThenRefreshEngineering
Create a new Java file named:HelloclientThe file content is as follows:
Import Java. util. list;
Import Java. util. arraylist;
public class Hello
{< br> Public String getname (string name)
{< br> return "hello" + name;
}< br> public list getlist ()
{< br> List list = new arraylist ();
list. add (0, "AA");
list. add (1, "BB");
list. add (2, "cc");
return list;
}< BR >}< br> now copy helloclient. java to the webroot directory and renamed it hello. JWS
Deploy the project and start the service
Start the browser and open the following link
Http: // localhost: 8080/axis/Hello. JWS? WSDL
3) create a test class:CodeAs follows:
Import java. util. arraylist;
Import java. util. List;
Import javax. xml. namespace. QNAME;
Import org. Apache. axis. Client. call;
Import org. Apache. axis. Client. Service;
Public class testaxis
{
Public static void main (string [] ARGs)
{
Try
{
String endpoint = "http: // localhost: 9000/axis/Hello. JWS ";
Service = new service ();
Call call = NULL;
Call = (CALL) service. createcall ();
Call. setoperationname (New QNAME (endpoint, "getname "));
Call. settargetendpointaddress (New java.net. URL (endpoint ));
String STR = (string) Call. Invoke (new object [] {"jian "});
System. Out. println (STR );
// This is a complex data type. You need to configure call. invoke to convert it.
// Call. setoperationname (New QNAME (endpoint, "getlist "));
// Call. settargetendpointaddress (New java.net. URL (endpoint ));
// List = (arraylist) Call. Invoke (new object [] {});
// System. Out. println (list. Size ());
}
Catch (exception ex)
{
Ex. printstacktrace ();
}
}
}
Note the need for 5 jar packages: axis. jar, SAAJ. jar, jaxrpc. jar, commons-logging-1.0.4.jar, commons-discovery-0.2.jar