Krishna Rajendra Alapati

IT Professional having 4+ years of experience on Java and JEE technologies. Good experience in working with Servlets, JSP, EJB2, XML, XSLT and JEE Design patterns. Good experience in working with open source frameworks like Struts, Spring, Hibernate, ANT, JUnit and JMock.

My Photo
Name:
Location: London, Ilford, United Kingdom

Tuesday, July 26, 2005

SOAP-Axis Installation process

SOAP BASICS

SOAP (Simple Object Access Protocol) :

SOAP is an XML-based messaging protocol. It defines a set of rules for structuring messages that can be used for simple one-way messaging but is particularly useful for performing RPC-style (Remote Procedure Call) request-response dialogues. SOAP is widely viewed as the backbone to a new generation of cross-platform cross-language distributed computing applications, termed Web Services.


AXIS


Axis is essentially a SOAP engine , a framework for constructing SOAP processors such as clients, servers, gateways, etc.

it also includes:

  • A simple stand-alone 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.



Axis Binary Zip File:

It also includes:

  • All the libraries needed to use axis

  • Some example programs

  • And the documentation how to install axis, how to deploy the services

      http://apache.towardex.com/ws/axis/1_2/axis-bin-1_2.zip
Unzip the above file and copy the axis folder, which is in webapps folder from the unzipped file to tomcat
webapps folder.
Create a environment variable called AXISCLASSPATH and put all the jar files which are in
the axis\WEB-INF\lib. And also need to put mail.jar,activation.jar and xerces.jar in class path.

Now start the Tomcat and test the axis using this URL: http://localhost:8080/axisOne page will come with header
as Apache-AXIS. This doesn't mean that apache axis is ready for deploying the services. To validate whether
all the settings configured correctly or not we can use Validation hyperlink in this page
http://localhost:8080/axis
List hyperlink will give the information about the services, which are already deployed in Apache-AXIS
By default AdministerAxis link will be disabled to enable this we need to remove the comment for this servlet entry in web.xml

Installing New Web Services:

So far we have got Axis installed and working successfully--now it is time to add our own Web Service.

Steps to deploy our service

  1. Get all the class files and library file needed for our service and copy it into the axis root directory, which is in webapps folder of the tomcat. if our service is in jar files we can place that jar into tomcat/webapps/axis/lib.

  2. Tell the Axis-Engine about the new service. This can be done by submitting an XML deployment descriptor to the service via the Admin web service, which is usually done with the AdminClient program. This deployment descriptor is called as Web Service Deployment Descriptor and has an extension of .wsdd . This file is a axis-specific xml file that tells Axis how to deploy (or undeploy) a Web Service, and how to configure Axis itself

In the sample examples we will see a example to deploy the sample webservice called stock.
in axis/samples/stock we can find a file called
deploy.wsdd
which is the web service deployment descriptor for this sample service .
go to the axis/samples/stock directory and run the below command

java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient
-lhttp://localhost:8080/axis/services/AdminService deploy.wsdd

we need to run the org.apache.axis.client.AdminClient with two arguments first one is the
URL
http://localhost:8080/axis/services/AdminService which is a admin service and the second one is
the wsdd file where we will describe our service.

The wsdd file looks like
<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="urn:xmltoday-delayed-quotes" provider="java:RPC">

<parameter name="className" value="samples.stock.StockQuoteService"/>
<parameter name="allowedMethods" value="getQuote test"/>
</service>
</deployment>
<deployment> is the root tag and having attributes name, namespaces
<service> is the child tag for the root and has two attributes name in which we need to
specify the urn i.e uniform resource name with which the service will be identified uniquely
and provider which is always “java:RPC” for a java service.

if you get a message like
<Admin>Done processing</Admin>
means our service is deployed successfully.

Test the service:
we can test the deployed service using a java client.for writing clients Apache-axis
has provided classes in this package org.apache.axis.client.*
Call ,Service etc.. are some of the classes given by Axis to write the
java clients.How to use this package to write java clients we have sample
examples given in the axis zip file.Here we will see how to test the service that we
deployed earlier with “urn:cominfo” using a XMLHTTPREQUEST Object.
First to call the service we need to create a XMLHTTPREQUEST object and
need to set some RequestHeaders.We can create XMLHTTPREQUEST object in mozilla by
the following statemnt.

xmlHTTP = new XMLHttpRequest();
in my case Uri is "
http://localhost:8080/axis/servlet/AxisServlet" as my host is
localhost and my port is 8080 and the axis/servlet/AxisServlet is the servlet which
will fetch the service and call the service method by using the details given in SOAP
Envolope.

xmlHTTP.open( "POST", Uri, true);

The Header given below is the important one for a SoapRequest.i.e a SOAPAction urn
is uniform resource name which is unique name that we have given for our service
( in our service this is xmltoday-delayed-quotes in which we need to call method
getQuote )

xmlHTTP.setRequestHeader( "SOAPAction","urn:mltoday-delayed-quotes#getQuote");

and finally send the request using

xmlHTTP.send(soapRequest);
for our service the soapRequest is given below
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getQuote xmlns:ns1="urn:xmltoday-delayed-quotes" SOAP-ENV:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/">
<nameToLookup xsi:type="xsd:string">XXX</nameToLookup>
</ns1:getQuote>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
then it will give response if response code is 200.it will give
a response xml with quote for XXX as 55.25

Advanced Installation: adding Axis to your own Webapp

  1. Add axis.jar, wsdl.jar, saaj.jar, jaxrpc.jar and the other dependent libraries to your WAR file.

  2. Copy all the Axis Servlet declarations and mappings from axis/WEB-INF/web.xml and add them to your own web.xml

  3. Build and deploy your webapp.

  4. Run the Axis AdminClient against your own webapp, instead of Axis, by changing the URL you invoke it with.



For more details you can visit: http://ws.apache.org/axis/java/install.html
or you can see the docs folder in the unzipped folder of the axis binary zip file.

pl/sql dbms_lob package

length() will return integer but not more than 4000 characters if parameter is of type VARCHAR
2000 characters if parameter is of type CAHR.

For finding the length of the LOB Objects we can use DBMS_LOB.GETLENGTH( LOB ) which will return INTEGER