|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 4 of 5
To deploy the service with a configuration file, follow these steps:
javaworld\axis directory in the TOMCAT_HOME\webapps\axis\WEB-INF\classes\ directory.
HelloServer.java and copy the resulting HelloServer.class into the Axis directory created in Step 2. You don't need to set a CLASSPATH to compile HelloServer.java.
set CLASSPATH=C:\axis-1_0\lib\axis.jar;C:\axis-1_0\lib\log4j-core.jar;C:\xerces-1_4_4\xerces.jar java org.apache.axis.client.AdminClient deploy.xml
Here, deploy.xml is a file that contains the configuration XML shown above, not the WSDD form. If you want to test the newly deployed Web
service, just change the following line in the client:
String endpoint = "http://localhost:8080/axis/HelloServer.jws";
to:
String endpoint = "http://localhost:8080/axis/servlet/AxisServlet";
Also replace this line:
String ret = (String)client.invoke("","sayHelloTo",new Object [] {args[0]});
with:
String ret = (String)client.invoke("HelloServer","sayHelloTo",new Object[]{args[0]});
This time, instead of the endpoint being a .jws file, it is the AxisServlet. The servlet locates and instantiates an instance of the class corresponding to the service name HelloServer and converts the SOAP messages into Java calls. The servlet then invokes the Java calls on the instantiated service class.
Most toolkits used for client-side Web services development are criticized because they require the client to have protocol-specific (e.g., SOAP-specific) knowledge. Overcoming this shortcoming has garnered much interest since Web services are protocol independent. IBM has been working on a toolkit called the Web Services Invocation Framework (WSIF), which abstracts all SOAP knowledge and instead works directly off the WSDL service description.
Similarly, in "Clean Up Your Wire Protocol with SOAP, Part 4," I created a class based on Java dynamic proxies that would abstract all SOAP details and make using SOAP-based services
as intuitive as using any other Java class. Axis does that as well, but in a different way. Axis takes Apache SOAP one step
further; it understands WSDL. WSDL is an XML-based language for describing Web services. You can use Axis to create a proxy
(or stub) for your clients to abstract away SOAP and thus ease client-side development; it's simple. Just run the wsdl2java
tool using the following commands from the directory that contains the javaworld.axis package:
set CLASSPATH=C:\axis-1_0\lib\axis.jar; C:\axis-1_0\lib\log4j-core.jar;C:\xerces-1_4_4\xerces.jar; C:\axis-1_0\lib\wsdl4j.jar;C:\axis-1_0\lib\clutil.jar java org.apache.axis.wsdl.Wsdl2java -p javaworld.axis.proxy http://localhost:8080/axis/HelloServer.jws?wsdl
wsdl2java creates Java classes from a Web service's WSDL description. Axis automatically generates WSDL for any deployed service
when you append ?wsdl to the end of the service endpoint URL.
Now change the client as shown below:
package javaworld.axis;
public class Client2
{
public static void main(String[] args) throws Exception
{
javaworld.axis.proxy.HelloServer server = new javaworld.axis.proxy.HelloServer();
javaworld.axis.proxy.HelloServerPortType port = server.getHelloServerPort();
// make the call
String ret = port.sayHelloTo(args[0]);
System.out.println(ret);
}
}
Wow, that's neat! The client now interacts with the Web service in WSDL terms instead of SOAP terms. SOAP is completely abstracted away, and the client is now protocol neutral. You can try it by compiling the client as follows: