Two days before two days wrote two blogs develop Java Web services - Axis development plan, in-depth exploration SOAP1.1 - use saaj1.2.1, some readers may complain about Java's Web service development, what is so complicated? It's better to knock a few keys under the NET platform, :) To discuss, a high-level Web service implementation scheme is based on JAX-RPC service implementation. The JAX-RPC 1.1 specification does not define any APIs for implementing JAX-RPC-based services. JAX-RPC-based services can use Java classes or use WSDL document implementations, both of them, JAX-RPCs do not have any requirements for their server to access and use deployment services. JAX-RPC-based service is extremely similar to the development of RMI applications (JAX-RPC is a web service that uses SOAP-based RPC and WSDL mechanisms to call the heterologous environment, integrating the performance of remote process calls (RPC), by providing Java The map required between XML / WSDL encapsulates the complex operation of the underlying SOAP packaging and message exchange). 1. Develop JAX-RPC services based on Java class. Steps are basically similar to RMI development: 1) Define remote interface (service definition); 2) Implementation remote interface (service implementation scheme); 3) Configure service; 4) Generate a deployment file; I implemented: 1. Define remote interface (StudentInfoif.java): / ** * StudentInfoif.java * Copyright 2005-2-10 * @ Author Affei * / package edu.cun.jws.jaxrpc;
Import java.rmi.remote; import java.rmi.remoteexception;
/ ** * This interface is primarily used for JAX-RPC service definition (remote interface) * / public interface studentinfoif extends remote {/ ** * @ param studentname This is a string of student names * @ return String Returns the information of students * / public String getStudentInfo (String studentName) throws RemoteException;} 2, remote interfaces (StudentInfoImpl.java): / ** * StudentInfoImpl.java * Copyright 2005-2-10 * @ author punk * / package edu.cun.jws .jaxrpc; import java.rmi.remote; import java.rmi.RemoteException;
/ ** * Remote Interface StudentInfoIF, service implementation * @ see StudentInfoIF * / public class StudentInfoImpl implements StudentInfoIF {public String getStudentInfo (String studentName) {System.out.println ( "Your name:" studentName); return new String ("Hello");}} Compiles the above source file: java * .java -d. Finally, you can get an EDU folder in the current folder, which is the byte class of our services.
3. Preparing for deployment is due to the use of JWSDP1.5 development tools, readers please go to the Sun website to download the JWSDP development tool http://java.sun.com/webservices/downloads/webservicesPack.html: We use JWSDP installation path / JAXRPC The tool WSDeploy in / bin, this tool first completed compilation by calling wscompile -gen: server (because the object we deployed now is Tomcat, so we want to call WSDeploy, if it is the container of the standard J2EE implementation, use WSCompile to play If you are using WSDeploy, you should write a jaxrpc-ri.xml file, for our example: XML Version = "1.0" encoding = "UTF-8"? >