Interview Questions On Java,Java EE


Enter your email address:



Add to Technorati Favorites
Google PageRank Checker
Showing posts with label AXIS. Show all posts
Showing posts with label AXIS. Show all posts

Thursday, April 17, 2008

Apache AXIS with IBM's WSAD/RAD

All major IDEs from different Vendors support webservices using Apache Axis.In this post my objective is to demonstrate a simple web service development and deployment using IBM's Websphere Application Developer(WSAD)/Rational Application Developer(RAD).They both provide support for Apache Axis and can use Axis libraries as required for runtime environment for web services.

In following heads all the steps involved are explained:

Configure Axis as runtime for Web services in RAD

-Start RAD/WSAD. Open a new workspace, and close the welcome screen.
-In WSAD/RAD,go on menu, Window >Preferences >Web Services >Server and Runtime
Do the settings for Apache Axis runtime as shown in the Figure 1.



Figure 1



Create a new Web Project

Now we have a plain java class and a web project. Next step is to create a web service out of this class and embed it into this Web project
-Switch to J2EE perspective, and create a new Dynamic Web project with name 'AxisExample'.


Figure 2

Create a simple java class which you want to expose as a web service.


Figure 3

Write any method which you want to access through WebService

Figure 4

Now you have a simple java class and a web project. The next step is to create a web service out of this class and embed it into this Web project.

For creating Web Service switch to J2EE Perspective



Figure 5


Select wizard to create a Web Service


Figure 6

Select Web Service type as desired (in this case select Java Bean Web Service)

Figure 7
Select the class created earlier as Java bean


Figure 8


If you select to generate proxy then the wizard will also ask you to select client type, for which proxy is to be generated



Figure 9


In this step you may have to manually select Axis as runtime if not default selected. And also you have to select the Web project just created as service project and also the server instance on which you want deploy this Web Service

On clicking next, a warning will pop up Ignore this warning, this is because RAD uses an older version of axis.

Figure 10


Now we are ready to generate and deploy the web service !

Figure 11


If you want to test this service, click on launch in next screen.



Figure 12


And you get the output as shown in the figure 13 in web-browser


Figure 13


Now let us generate proxy for this web service through wizard


Figure 14


Select the methods you want to add in the proxy generated


Figure 15

Generated Proxy Classes when you view them in J2EE perspective



Figure 16

Testing through browser




Figure 17

WSDL file generated by axis. This is visible at http:// <web service uri>?wsdl





Figure 18

Test Client using Generated Proxy



Figure 19

Test Client using Axis API



Figure 20

Labels: , , , ,

Continue reading...

Webserivces With Apache Axis Continued...

In continuation with my previous post,this post explores various ways of deploying a webservice using Apache Axis and how stubs can be generated with tools provided in Apache Axis.

Deploying A Webservice:
Web services can be deployed in axis in two ways
-JWS (Java Web Service) Files - Instant Deployment
-Custom Deployment - Introducing WSDD

JWS Deployment:
-Copy the *.java file into your web directory, and rename it *.jws.
-You're done!
You should now be able to access the service at the following URL (assuming your Axis web application is on port 8080):
http://localhost:8080/axis/Calculator.jws
Axis automatically locates the file, compiles the class, and converts SOAP calls correctly into Java invocations of your service class

Custom Deployment - Introducing WSDD:
Axis uses *.wsdd files to deploy Web services. This is a Axis specific format for deploying custom web services.

Steps to Deploy a Class File as Webservice:
-Create the class file.
-Write a deploy.wsdd file for that class
-Run AdminClient as follows :
java org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis deploy.wsdd
-Done !
Now you'll be able to view this web service wsdl file at the path
http://localhost:8080/axis/services/MyService?wsdl

Generating Stubs For A Web Service:
-Run following command at the command prompt
java org.apache.axis.wsdl.WSDL2Java -v -p -o
Here is an exmaple
java org.apache.axis.wsdl.WSDL2Java -v -p com.punsoft.ws.client.generated

http://localhost:9080/WSAxis/services/HelloWorldEJBService?wsdl–o javasource/com/punsoft/ws/client/generated
Continue reading...

Wednesday, April 16, 2008

Webservices, Apache Axis Way

AXIS,is a complete frame work for developing and assessing Web Services.The current stable version of Axis in use is 1.2,though Axis 2 is on the anvil of release.You can find more information and download information about Axis C++ and Java on their official website.

Axis is essentially a SOAP engine.It is an implemetation of SOAP which provides abstarction from dealing with SOAP and WSDL directly.You can always write webservices without Axis but it will be a very tedious job then.

Axis2 is SOAP 3.0 which is written from scratch,the intention is to create a more modular, more flexible, and higher-performing SOAP implementation (relative to Apache SOAP 2.0).

Axis provides a framework for constructing SOAP processors such as clients, servers, gateways, etc. Axis supports both Java and C++.
But Axis isn't just a SOAP engine -- it also includes:

-a simple standalone server.
-a server which plugs into servlet engines such as Tomcat.
-extensive support for the Web Service Description Language (WSDL)
-emitter tooling that generates Java classes from WSDL.
-some sample programs, and a tool for monitoring TCP/IP packets.

Services provided by AXIS:-

A soap Engine that accepts and responds SOAP messages. This is deployed as a Web Application on a Web/Application server

-AdminService : A Web service comes by default in AXIS that helps in deploying/ undeploying another Web Services

-AxisServlet : A Servlet deployed in AXIS that helps in Calling of another Web Services-API to Access and call any web service (This internally uses javax.xml.rpc)

-org.apache.axis.client.AdminClient :Tool to deploy a piece of code as web service into the Soap Engine.

-org.apache.axis.wsdl.WSDL2Java : Tool to generate java stub from a WSDL file.

-org.apache.axis.wsdl.Java2WSDL : Tool to generate a WSDL file from a java class or interface.



Deploying AXIS:-

Download the Axis binary from there website

-Extract the zip file and locate axis folder inside webapps
-You can directly deploy the axis into the Web- server ( if it allows you so), by copying the axis into the deployment folder of Web server, e.g. webapps in Tomcat.
-If web server is running on port 8080 in local machine that axis will be running at http://localhost:8080/axis

Continue reading...
 

Disclaimer
Interview Questions On Java,Java EE Copyright © 2016. Reads: best tracker