About Java Web Services with Axis and JAX-RPC in Eclipse




Follow the steps for creating he simple Axis and JAX-RPC, Service and Client code with Examples:

Step 1. List of software required for this application if not found in your system, install it:

Step 2. Extract the xml-axis-rc1-bin.zip into your local system

  • Navigate till \xml-axis-rc1-bin\axis-1_0\webapps and copy the axis folder

Step 3. Pest the axis folder (Already copy in above step) into Tomcate x.x \webapps

Step 4. Restart your Tomcate x.x

Step 5. Open the browser and type the http://localhost:port/axis

Note: if tools.jar file is not there in xml-axis-rc1-bin\axis-1_0\webapps\axis\WEB-INF\lib then copy from \jdk1.6.0_26\lib.

Now environment is configured on and off, need service & client code.

Step 6. Server Side Code

//File name : TestServerSideCode.jws save the file ext with jws insteed of java
public class TestServerSideCode{
public String testServerSideCode()
{
return "Working";
}
}

Step 7. Save TestServerSideCode.jws file into \Tomcat x.x\webapps\axis folder

Step 8. Restart the Tomcate x.x

Open the browser and invoke the http://localhost:port/axis/TestServerSideCode.jws?wsdl

Step 9. Client Side code with Dynamic Invocation Interface (DII)

TestClientSideCode.java

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

public class TestClientSideCode
{
public static void main(String [] args) {
try {
String endPointURL = "http://localhost:8090/axis/TestServerSideCode.jws";

Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName("http://localhost:8090/axis/TestServerSideCode.jws?wsdl", "testServerSideCode"));
call.setTargetEndpointAddress( new java.net.URL(endPointURL) );

String response = (String) call.invoke( new Object[] {} );

System.out.println(" Test data " + response);
} catch (Exception e) {
System.err.println("Exception: " + e);
}
}
}


Step 10. Save the TestClientSideCode.java in your local drive e.g C:\Blogs\AxisWithJAXRPC

Step 11. Open the cmd prompt, type cd then C:\Blogs\AxisWithJAXRPC

Step 12. Copy and pest the below command in command prompt with above steps

set AXIS_HOME=C:\Blogs\xml-axis-rc1-bin\axis-1_0

set CLASSPATH=.;%AXIS_HOME%\lib\axis.jar;%AXIS_HOME%\lib\axis-ant.jar;%AXIS_HOME%\lib\commons-discovery.jar;%AXIS_HOME%\lib\commons-logging.jar;%AXIS_HOME%\lib\jaxrpc.jar;%AXIS_HOME%\lib\saaj.jar;%AXIS_HOME%\lib\wsdl4j.jar;%AXIS_HOME%\lib\log4j-1.2.4.jar

Note: Change the location of xml-axis-rc1-bin\axis-1_0 in your system

Step 13. Compile the TestClientSideCode.java file with C:\Blogs\AxisWithJAXRPC>javac TestClientSideCode.java

Step 14. Run the same C:\Blogs\AxisWithJAXRPC>java TestClientSideCode

You will get out put as Test data Working



Done form my end, must try and do at your end and do let me know if any concerns.

Happy learning and implementation!!!

1 comment:

  1. It's a top-rated Minnesota website design company, digital marketing agency. You can click here to visit their website proweb365.com

    ReplyDelete