Interview Questions On Java,Java EE


Enter your email address:



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

Thursday, April 17, 2008

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...

Tuesday, April 15, 2008

How to register Web Services with UDDI4j?

Here we go with a snippet of code to register a web service using UDDI4j

****BEGIN****

proxy.setPublishURL(uddiPublishingURI);
AuthToken token = proxy.get_authToken(mUserName, mPassword);
Vector entities = new Vector();
BusinessEntity be = new BusinessEntity("", mBusinessEntityName);// set all related data

BusinessDetail bd = proxy.save_business(token.getAuthInfoString(), entities);
Vector businessEntities = bd.getBusinessEntityVector();
BusinessEntity returnedBusinessEntity = (BusinessEntity) (businessEntities.elementAt(0));
mServiceKey = returnedBusinessEntity.getBusinessServices().get(0).getServiceKey();

****END****

'mServiceKey' will be used to extract to get URL of a registered Service from a UDDI Registry,and here is another snippet which helps you in locating a service :

****BEGIN****

UDDIProxy proxy = new UDDIProxy();
proxy.setInquiryURL("http://localhost:9090/juddi/inquiry");
ServiceDetail serviceDetail = proxy.get_serviceDetail(mServiceKey);
Vector businessServiceVector = new Vector();
businessServiceVector = serviceDetail.getBusinessServiceVector();
BusinessService returnedBusinessService = (BusinessService) (businessServiceVector.get(0));
AccessPoint = returnedBusinessService.getBindingTemplates().get(0).getAccessPoint().getText();

****END****

Now the whole picture with all its ingredients put together makes webservice functioning.

Individually, any one of these technologies(SOAP,UDDI,WSDL etc) is only evolutionary. Each provides a standard for the next step in the advancement of web services, their description, or their discovery.

However, one of the big promises of web services is seamless, automatic business integration:

A piece of software will discover, access, integrate, and invoke new services from unknown
companies dynamically without the need for human intervention.

Dynamic integration of this nature requires the combined involvement of SOAP, WSDL, and UDDI to provide a dynamic, standard infrastructure for enabling the dynamic business of tomorrow.

Combined, these technologies are revolutionary because they are the first standard technologies to offer the promise of a dynamic business. In the past, technologies provided features equivalent to SOAP, WSDL, and UDDI in other languages, but they weren't supported by every major corporation and did not have a core language as flexible as XML.
Continue reading...
 

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