Welcome to Java4u

A Single Place for all Java Resources

Looking for something?

Subscribe to this blog!

Receive the latest posts by email.

.Just enter your email below if you want to subscribe!

Email

OAuth 2.0

OAuth 2.0 is an open authorization framework and mainly focuses on authorization flows fand secures access to many well-known web APIs.

Java 8 features

The key features of JDK 8 are Project Lambda (JSR 335), the Nashorn JavaScript Engine, a new Date and Time API (JSR 310), a set of Compact Profiles and the removal of the "permanent generation" from the HotSpot Java Virtual Machine (JVM). A complete list of the new features and capabilities of JDK 8 is available.

Lambda Expression

A lambda expression represents an anonymous function. It comprises of a set of parameters, a lambda operator (->) and a function body.

SOAP vs RESTful

SOAP : Web service use XML messages that follow the Simple Object Access Protocol (SOAP) standard.
RESTful : Web service, often better integrated with HTTP than SOAP-based services are, do not require XML messages or WSDL service–API definitions.

Softwares Engineering / SDLC

Software engineers apply the principles of engineering to the design, development, maintenance, testing, and evaluation of the software and systems that make computers or anything containing software work.

Friday, June 27, 2014

XML Schema using JAXB in Eclipse IDE

Tuesday, June 24, 2014

WSDL Explaination


WSDL describes Web Services
WSDL stands for Web Services Description Language.
WSDL is a document written in XML. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes.
A WSDL document is just a simple XML document.
It contains set of definitions to describe a web service.
WSDL should have methods, input arguments for methods & return type for methods

Let’s take an example with one method

If we mention @WebMethod(exclude=true), it is not going to publish this method when ever access specified is public also
1) portType: This tag is  an element, contains  name attribute of service class name[ProductCatalog].
Inside Operations the sub element ,contains the name attribute of service class, service method name[getProductCategories()].

In Operation tag, two tags  are defined which takes input and output .

Here Input  is the Request  and sends like getProductCateogriesRequest.

Here Output  is the Response  and sends like getProductCateogriesResponse.

If we have multiples arguments  defined in method, there are bundled together as a message.
Every input is takes a message & output is given as message

Operation takes I/p as one message and o/p as one message

2) types : if we have custom data types ,  we need to define it over here in this types tags & input  and output are referenced for these types.

3)message : Here message has as attribute name which is same as operation name & this message is declared in input tag under message attribute & in output message with suffix at last Response &  message has a sub element tag with name part and name as parameters which are the arguments in the service method

4)binding : WSDL defines  some binding’s information , how web service accepts these request values & gives response

We have element called
 

[which means this web service accepts SOAP request over http]

5) service  : it’s a list of ports ,

where service  name is  suffixed with the name  service at last

(ProductCatalog{Service}) ==> ProductCatalogService

sub element tag is port where name is  suffixed with the name  Port at last

(ProductCatalog{Port}) ==> ProductCatalogPort

& binding attribute also  and we have another sub element for port

i.e...  

this is the location where web service is available & Service has a Port, which follows the binding

Server : Glassfish

1)When ever the server see a class with @WebService annotation, it’s going to create a Service & a Port with class name  & the ports has bindings how the web service is going get  called  with soap over http.

2) Coming to methods they are annotated with @WebMethod, its gone create operations for that , so port consists of operations And it consist of message of types & types are defined

  • Service consists port
  • port defines bindings
  • bindings  points to portType & which has operations
  • operations has an input & output & I/p & o/p message
  • message refers to types
  • types are defined in own section.




SOAP:JAX-WS

Web services are client and server applications that communicate over the World Wide Web’s (WWW) HyperText Transfer Protocol (HTTP). As described by the World Wide Web Consortium (W3C), web services provide a standard means of interoperating between software applications running on a variety of platforms and frameworks. Web services are characterized by their great interoperability and extensibility, as well as their machine-processable descriptions, thanks to the use of XML. Web services can be combined in a loosely coupled way to achieve complex operations. Programs providing simple services can interact with each other to deliver sophisticated added-value services. 
  • Web service can be written in any language java, .net, c++, python etc..;
  • Web service standard in interoperability (java web service can call .net code) & (java code can call .net web service)
Web services use XML messages that follow the Simple Object Access Protocol (SOAP) standard, an XML language defining a message architecture and message formats. Such systems often contain a machine-readable description of the operations offered by the service, written in the Web Services Description Language (WSDL), an XML language for defining interfaces syntactically.
 
E.g. let’s take getProducts () as a method as created a business service for it & this business service is deployed in your application server.
Here A, B & C are this .classes in the same application server & they are free to call this java  method to get the list of products .And if u want to provide this feature to users, so u could have like MVC Module that makes this available as a web application
 So the user can actually enter the URL and can see the list of products on their web browser, which is actually making call to this web service method getProducts(), so the MVC module  has a call to getProducts() & shows the products in a nice HTML designed format.
Lets take another server 2  in another machine , which contains one deployed application, and from this application we want to call this getProducts () method & show list of all products in this application.
Yes this is possible by packaging the business service method in .jar file, and deploying this jar file in this server2 & calling the business method   which is available in the jar file & this getProducts() is calling to a database, which has the list of products & this database is hosted along the sever 1 .

Dis-advantages:
  1. Server 2 has different database structure &  here data base which is hosted with server 1 has different products list which we are not interested.
  2. And when we create a version 2 for  getProducts(), we need to re- package the .jar file  & application need to rebuild and redeploy in server 2, by this way the new functionality is provided in machine server 2
Advantages:
  1. If the getProducts() call could directly call the business service method which is hosted in server 1,if it would directly call the instance this would be the best to get the service & this instance is directly access to the database & when there is a version change & functionality change we will have the latest list of products.
  2. This directly call will be worked only by using WEB SERVICE. Here it will allow 2 different machines and 2 different codes to be able to talk to each other over the network by using web service technology.