Cia 2 MW

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

What is .

NET Framework
It is a virtual machine that provide a common platform to run an application that was
built using the different language such as C#, VB.NET, Visual Basic, etc.

It is also used to create a form based, console-based, mobile and web-based


application or services that are available in Microsoft environment.

Furthermore, the .NET framework is a pure object oriented, that similar to the Java


language. But it is not a platform independent as the Java. So, its application runs
only to the windows platform.

The main objective of this framework is to develop an application that can run on
the windows platform. The current version of the .Net framework is 4.8.

Components of .NET Framework


There are following components of .NET Framework:

1. CLR (Common Language Runtime)


2. CTS (Common Type System)
3. BCL (Base Class Library)
4. CLS (Common Language Specification)
5. FCL (Framework Class Library)
6. .NET Assemblies
7. XML Web Services
8. Window Services

CLR (common language runtime)

It is an important part of a .NET framework that works like a virtual component of the
.NET Framework to executes the different languages program like c#, Visual Basic,
etc. A CLR also helps to convert a source code into the byte code, and this byte code
is known as CIL (Common Intermediate Language) or MSIL (Microsoft Intermediate
Language).

After converting into a byte code, a CLR uses a JIT compiler at run time that helps to
convert a CIL or MSIL code into the machine or native code.

CTS (Common Type System)

It specifies a standard that represent what type of data and value can be defined
and managed in computer memory at runtime.

A CTS ensures that programming data defined in various languages should interact
with each other to share information. For example, in C# we define data type as int,
while in VB.NET we define integer as a data type.

BCL (Base Class Library)

The base class library has a rich collection of libraries features and functions that help
to implement many programming languages in the .NET Framework, such as C #, F #,
Visual C ++, and more. Furthermore, BCL divides into two parts:

1. User defined class library


o Assemblies - It is the collection of small parts of deployment an
application's part. It contains either the DLL (Dynamic Link Library) or
exe (Executable) file.
1. In LL, it uses code reusability, whereas in exe it contains only
output file/ or application.
2. DLL file can't be open, whereas exe file can be open.
3. DLL file can't be run individually, whereas in exe, it can run
individually.
4. In DLL file, there is no main method, whereas exe file has main
method.
2. Predefined class library
o Namespace - It is the collection of predefined class and method that
present in .Net. In other languages such as, C we used header files, in
java we used package similarly we used "using system" in .NET, where
using is a keyword and system is a namespace.

CLS (Common language Specification)

It is a subset of common type system (CTS) that defines a set of rules and regulations
which should be followed by every language that comes under the .net framework.

In other words, a CLS language should be cross-language integration or


interoperability. For example, in C# and VB.NET language, the C# language
terminate each statement with semicolon, whereas in VB.NET it is not end with
semicolon, and when these statements execute in .NET Framework, it provides a
common platform to interact and share information with each other.

Microsoft .NET Assemblies

A .NET assembly is the main building block of the .NET Framework. It is a small unit
of code that contains a logical compiled code in the Common Language
infrastructure (CLI), which is used for deployment, security and versioning.

It defines in two parts (process) DLL and library (exe) assemblies. When the .NET
program is compiled, it generates a metadata with Microsoft Intermediate Language,
which is stored in a file called Assembly.

FCL (Framework Class Library)

It provides the various system functionality in the .NET Framework, that includes
classes, interfaces and data types, etc. to create multiple functions and different types
of application such as desktop, web, mobile application, etc.

In other words, it can be defined as, it provides a base on which various applications,
controls and components are built in .NET Framework.

EJB:
EJB is an acronym for enterprise java bean. It is a specification provided by Sun
Microsystems to develop secured, robust and scalable distributed applications.

Enterprise Java Beans (EJB) is one of the several Java APIs for standard
manufacture of enterprise software. EJB is a server-side software
element that summarizes business logic of an application.
To run EJB application we need an application server (EJB Container) such
as Jboss, Glassfish, Weblogic, Websphere etc. It performs:

1. Life cycle management 


2. Security 
3. Transaction management 
4. Object pooling 

Types of Enterprise Java Beans


There are three types of EJB: 
1. Session Bean: Session bean contains business logic that can be invoked
by local, remote or webservice client. There are two types of session beans:
(i) Stateful session bean and (ii) Stateless session bean. 
 
 (i) Stateful Session bean : 
Stateful session bean performs business task with the help of a
state. Stateful session bean can be used to access various method
calls by storing the information in an instance variable. Some of
the applications require information to be stored across separate
method calls. In a shopping site, the items chosen by a customer
must be stored as data is an example of stateful session bean. 
 
 (ii) Stateless Session bean : 
Stateless session bean implement business logic without having a
persistent storage mechanism, such as a state or database and can
used shared data. Stateless session bean can be used in situations
where information is not required to used across call methods. 
 
2. Message Driven Bean: Like Session Bean, it contains the business logic
but it is invoked by passing message. 
3. Entity Bean: It summarizes the state that can be remained in the
database. It is deprecated. Now, it is replaced with JPA (Java Persistent
API). There are two types of entity bean: 
 
 (i) Bean Managed Persistence : 
In a bean managed persistence type of entity bean, the
programmer has to write the code for database calls. It persists
across multiple sessions and multiple clients. 
 
 (ii) Container Managed Persistence : 
Container managed persistence are enterprise bean that persists
across database. In container managed persistence the container
take care of database calls. 
 
 When to use Enterprise Java Beans
1.Application needs Remote Access. In other words, it is distributed. 
2.Application needs to be scalable. EJB applications supports load
balancing, clustering and fail-over. 
3.Application needs encapsulated business logic. EJB application is
differentiated from demonstration and persistent layer. 

EJB Implementation:
Enter session bean name and package name. Click Finish button. You will see the following
EJB classes created by NetBeans.
 LibrarySessionBean − stateless session bean
 LibrarySessionBeanRemote− local interface for session bean
 LibrarySessionBeanRemote
 package com.tutorialspoint.stateless;

 import java.util.List;
 import javax.ejb.Remote;

 @Remote
 public interface LibrarySessionBeanRemote {
 void addBook(String bookName);
 List getBooks();
 }
LibrarySessionBean
package com.tutorialspoint.stateless;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;

@Stateless
public class LibrarySessionBean implements LibrarySessionBeanRemote {

List<String> bookShelf;

public LibrarySessionBean() {
bookShelf = new ArrayList<String>();
}

public void addBook(String bookName) {


bookShelf.add(bookName);
}

public List<String> getBooks() {


return bookShelf;
}
}
Clean, build , deploy the project.
Client access to the application:
Create a new java applicatioin.
 Add EJB component project created earlier under libraries using Add
Project button in compile tab.
 Add jboss libraries using Add jar/folder button in compile tab. Jboss libraries
can be located at <jboss installation folder>> client folder

EJBTester.java:
package com.tutorialspoint.test;

import com.tutorialspoint.stateless.LibrarySessionBeanRemote;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class EJBTester {


BufferedReader brConsoleReader = null;
Properties props;
InitialContext ctx;
{
props = new Properties();
try {
props.load(new FileInputStream("jndi.properties"));
} catch (IOException ex) {
ex.printStackTrace();
}
try {
ctx = new InitialContext(props);
} catch (NamingException ex) {
ex.printStackTrace();
}
brConsoleReader =
new BufferedReader(new InputStreamReader(System.in));
}
public static void main(String[] args) {

EJBTester ejbTester = new EJBTester();

ejbTester.testStatelessEjb();
}
private void showGUI() {
System.out.println("**********************");
System.out.println("Welcome to Book Store");
System.out.println("**********************");
System.out.print("Options \n1. Add Book\n2. Exit \nEnter Choice: ");
}
private void testStatelessEjb() {
try {
int choice = 1;
LibrarySessionBeanRemote libraryBean =
(LibrarySessionBeanRemote)ctx.lookup("LibrarySessionBean/remote");
while (choice != 2) {
String bookName;
showGUI();
String strChoice = brConsoleReader.readLine();
choice = Integer.parseInt(strChoice);
if (choice == 1) {
System.out.print("Enter book name: ");
bookName = brConsoleReader.readLine();
libraryBean.addBook(bookName);
}else if (choice == 2) {
break;
}
}
List<String> booksList = libraryBean.getBooks();
System.out.println("Book(s) entered so far: " + booksList.size());
for (int i = 0; i < booksList.size(); ++i) {
System.out.println((i+1)+". " + booksList.get(i));
}
LibrarySessionBeanRemote libraryBean1 =
(LibrarySessionBeanRemote)ctx.lookup("LibrarySessionBean/remote");
List<String> booksList1 = libraryBean1.getBooks();
System.out.println(
"***Using second lookup to get library stateless object***");
System.out.println(
"Book(s) entered so far: " + booksList1.size());
for (int i = 0; i < booksList1.size(); ++i) {
System.out.println((i+1)+". " + booksList1.get(i));
}
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
} finally {
try {
if(brConsoleReader !=null) {
brConsoleReader.close();
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
}
Soap:
SOAP stands for Simple Object Access Protocol. It is a XML-based protocol for
accessing web services.

SOAP is a W3C recommendation for communication between two applications.

Points to Note
1. SOAP is a communication protocol designed to communicate via Internet.
2. SOAP can extend HTTP for XML messaging.
3. SOAP provides data transport for Web services.
4. SOAP can exchange complete documents or call a remote procedure.
5. SOAP can be used for broadcasting a message.
6. SOAP is platform- and language-independent.
7. SOAP is the XML way of defining what information is sent and how.
8. SOAP enables client applications to easily connect to remote services and invoke
remote methods.

Soap Structure:

A SOAP message is an ordinary XML document containing the following elements −


 Envelope − Defines the start and the end of the message. It is a mandatory
element.
 Header − Contains any optional attributes of the message used in processing
the message, either at an intermediary point or at the ultimate end-point. It is
an optional element.
 Body − Contains the XML data comprising the message being sent. It is a
mandatory element.
 Fault − An optional Fault element that provides information about errors that
occur while processing the message.
Envelope:
 Every SOAP message has a root Envelope element.
 Envelope is a mandatory part of SOAP message.
 Every Envelope element must contain exactly one Body element.
 If an Envelope contains a Header element, it must contain no more than one,
and it must appear as the first child of the Envelope, before the Body.
 The envelope changes when SOAP versions change.
 The SOAP envelope is specified using the ENV namespace prefix and the
Envelope element.
 The optional SOAP encoding is also specified using a namespace name and the
optional encodingStyle element, which could also point to an encoding style
other than the SOAP one.

Soap with http:


POST /OrderEntry HTTP/1.1
Host: www.tutorialspoint.com
Content-Type: application/soap; charset="utf-8"
Content-Length: nnnn

<?xml version = "1.0"?>


<SOAP-ENV:Envelope
xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
SOAP-ENV:encodingStyle = " http://www.w3.org/2001/12/soap-encoding">
...
Message information goes here
...
</SOAP-ENV:Envelope>

Header:

 It is an optional part of a SOAP message.


 Header elements can occur multiple times.
 Headers are intended to add new features and functionality.
 The SOAP header contains header entries defined in a namespace.
 The header is encoded as the first immediate child element of the SOAP
envelope.
 When multiple headers are defined, all immediate child elements of the SOAP
header are interpreted as SOAP header blocks.
UDDI:

UDDI is an XML-based standard for describing, publishing, and finding web services.
 UDDI stands for Universal Description, Discovery, and Integration.
 UDDI is a specification for a distributed registry of web services.
 UDDI is a platform-independent, open framework.
 UDDI can communicate via SOAP, CORBA, Java RMI Protocol.
 UDDI uses Web Service Definition Language(WSDL) to describe interfaces to
web services.
 UDDI is seen with SOAP and WSDL as one of the three foundation standards
of web services.
 UDDI is an open industry initiative, enabling businesses to discover each other
and define how they interact over the Internet.
UDDI has two sections −
 A registry of all web service's metadata, including a pointer to the WSDL
description of a service.
 A set of WSDL port type definitions for manipulating and searching that
registry.

A business or a company can register three types of information into a UDDI registry. This
information is contained in three elements of UDDI.
These three elements are −

 White Pages,
 Yellow Pages, and
 Green Pages.
White Pages
White pages contain −
 Basic information about the company and its business.
 Basic contact information including business name, address, contact phone
number, etc.
 A Unique identifiers for the company tax IDs. This information allows others
to discover your web service based upon your business identification.
Yellow Pages
 Yellow pages contain more details about the company. They include
descriptions of the kind of electronic capabilities the company can offer to
anyone who wants to do business with it.
 Yellow pages uses commonly accepted industrial categorization schemes,
industry codes, product codes, business identification codes and the like to
make it easier for companies to search through the listings and find exactly
what they want.
Green Pages
Green pages contains technical information about a web service. A green page allows
someone to bind to a Web service after it's been found. It includes −

 The various interfaces


 The URL locations
 Discovery information and similar data required to find and run the Web service.
Creating registry:
 POST /save_business HTTP/1.1
 Host: www.XYZ.com
 Content-Type: text/xml; charset = "utf-8"
 Content-Length: nnnn
 SOAPAction: "save_business"

 <?xml version = "1.0" encoding = "UTF-8" ?>
 <Envelope xmlns = "http://schemas/xmlsoap.org/soap/envelope/">
 <Body>
 <save_business generic = "2.0" xmlns = "urn:uddi-org:api_v2">
 <businessKey = "">
 </businessKey>

 <name>
 XYZ, Pvt Ltd.
 </name>

 <description>
 Company is involved in giving Stat-of-the-art....
 </description>

 <identifierBag> ... </identifierBag>
 ...
 </save_business>
 </Body>
 </Envelope>

Retreiving information:

POST /get_businessDetail HTTP/1.1


Host: www.XYZ.com
Content-Type: text/xml; charset = "utf-8"
Content-Length: nnnn
SOAPAction: "get_businessDetail"

<?xml version = "1.0" encoding = "UTF-8" ?>


<Envelope xmlns = "http://schemas/xmlsoap.org/soap/envelope/">
<Body>
<get_businessDetail generic = "2.0" xmlns = "urn:uddi-org:api_v2">
<businessKey = "C90D731D-772HSH-4130-9DE3-5303371170C2">
</businessKey>
</get_businessDetail>
</Body>
</Envelope>

SOA:
A Service-Oriented Architecture or SOA is a design pattern which is designed to build
distributed systems that deliver services to other applications through the protocol. It is only
a concept and not limited to any programming language or platform.

Service: A Service-Oriented Architecture or SOA is a design pattern which is designed to


build distributed systems that deliver services to other applications through the protocol. It is
only a concept and not limited to any programming language or platform.

Service consumer sends a service request to the service provider, and the service provider
sends the service response to the service consumer. The service connection is
understandable to both the service consumer and service provider.

Terminologies:
o Services - The services are the logical entities defined by one or more
published interfaces.
o Service provider - It is a software entity that implements a service
specification.
o Service consumer - It can be called as a requestor or client that calls a service
provider. A service consumer can be another service or an end-user
application.
o Service locator - It is a service provider that acts as a registry. It is responsible
for examining service provider interfaces and service locations.
o Service broker - It is a service provider that pass service requests to one or
more additional service providers

Characteristics of SOA
The services have the following characteristics:

o They are loosely coupled.


o They support interoperability.
o They are location-transparent
o They are self-contained.

Components of service-oriented architecture


The service-oriented architecture stack can be categorized into two parts - functional
aspects and quality of service aspects.
Functional aspects

The functional aspect contains:

o Transport - It transports the service requests from the service consumer to the service
provider and service responses from the service provider to the service consumer.
o Service Communication Protocol - It allows the service provider and the service
consumer to communicate with each other.
o Service Description - It describes the service and data required to invoke it.
o Service - It is an actual service.
o Business Process - It represents the group of services called in a particular sequence
associated with the particular rules to meet the business requirements.
o Service Registry - It contains the description of data which is used by service
providers to publish their services.
Quality of Service aspects

The quality of service aspects contains:

o Policy - It represents the set of protocols according to which a service provider make
and provide the services to consumers.
o Security - It represents the set of protocols required for identification and
authorization.
o Transaction - It provides the surety of consistent result. This means, if we use the
group of services to complete a business function, either all must complete or none
of the complete.
o Management - It defines the set of attributes used to manage the services.

Advantages of SOA
SOA has the following advantages:

o Easy to integrate - In a service-oriented architecture, the integration is a service


specification that provides implementation transparency.
o Manage Complexity - Due to service specification, the complexities get isolated, and
integration becomes more manageable.
o Platform Independence - The services are platform-independent as they can
communicate with other applications through a common language.
o Loose coupling - It facilitates to implement services without impacting other
applications or services.
o Parallel Development - As SOA follows layer-based architecture, it provides parallel
development.
o Available - The SOA services are easily available to any requester.
o Reliable - As services are small in size, it is easier to test and debug them.

WSDL:
WSDL stands for Web Services Description Language. It is the standard format for
describing a web service. WSDL was developed jointly by Microsoft and IBM.

Features of WSDL
 WSDL is an XML-based protocol for information exchange in decentralized
and distributed environments.
 WSDL definitions describe how to access a web service and what operations it
will perform.
 WSDL is a language for describing how to interface with XML-based services.
 WSDL is an integral part of Universal Description, Discovery, and Integration
(UDDI), an XML-based worldwide business registry.
 WSDL is the language that UDDI uses.
 WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'.
WSDL Usage
WSDL is often used in combination with SOAP and XML Schema to provide web services
over the Internet.
A client program connecting to a web service can read the WSDL to determine what
functions are available on the server. Any special datatypes used are embedded in the WSDL
file in the form of XML Schema.

WSDL elements
The three major elements of WSDL that can be defined separately are −

 Types
 Operations
 Binding
The client can then use SOAP to actually call one of the functions listed in the WSDL.
WSDL breaks down web services into three specific, identifiable elements that can be
combined or reused once defined.
The three major elements of WSDL that can be defined separately are −

 Types
 Operations
 Binding
A WSDL document has various elements, but they are contained within these three main
elements, which can be developed as separate documents and then they can be combined or
reused to form complete WSDL files.

WSDL Elements
A WSDL document contains the following elements −
 Definition − It is the root element of all WSDL documents. It defines the name
of the web service, declares multiple namespaces used throughout the
remainder of the document, and contains all the service elements described
here.
 Data types − The data types to be used in the messages are in the form of
XML schemas.
 Message − It is an abstract definition of the data, in the form of a message
presented either as an entire document or as arguments to be mapped to a
method invocation.
 Operation − It is the abstract definition of the operation for a message, such as
naming a method, message queue, or business process, that will accept and
process the message.
 Port type − It is an abstract set of operations mapped to one or more end-
points, defining the collection of operations for a binding; the collection of
operations, as it is abstract, can be mapped to multiple transports through
various bindings.
 Binding − It is the concrete protocol and data formats for the operations and
messages defined for a particular port type.
 Port − It is a combination of a binding and a network address, providing the
target address of the service communication.
 Service − It is a collection of related end-points encompassing the service
definitions in the file; the services map the binding to the port and include any
extensibility definitions.
In addition to these major elements, the WSDL specification also defines the following utility
elements −
 Documentation − This element is used to provide human-readable
documentation and can be included inside any other WSDL element.
 Import − This element is used to import other WSDL documents or XML
Schemas.
NOTE − WSDL parts are usually generated automatically using web services-aware tools.

The WSDL Document Structure


The main structure of a WSDL document looks like this −
<definitions>
<types>
definition of types........
</types>

<message>
definition of a message....
</message>

<portType>
<operation>
definition of a operation.......
</operation>
</portType>

<binding>
definition of a binding....
</binding>

<service>
definition of a service....
</service>
</definitions>
A WSDL document can also contain other elements, like extension elements and a service
element that makes it possible to group together the definitions of several web services in one
single WSDL document.

You might also like