Sie sind auf Seite 1von 7

Web Services Tutorial

=====================
First, a Web service can have a public interface, defined in a common XML gramma
r. The interface describes all the methods available to clients and specifies th
e signature for each method. Currently, interface definition is accomplished via
the Web Service Description Language (WSDL).
Second, if you create a Web service, there should be some relatively simple mech
anism for you to publish this fact. Likewise, there should be some simple mechan
ism for interested parties to locate the service and locate its public interface
. The most prominent directory of Web services is currently available via UDDI (
Universal Description, Discovery, and Integration).
Behind the scenes, it ties together SOAP, WSDL, and UDDI to provide a simple plu
g-and-play interface for finding and invoking Web services.
The Web service protocol stack is an evolving set of protocols used to define, d
iscover, and implement Web services. 4 layers
Service Transport: This layer is responsible for transporting messages between a
pplications. Currently, this includes HTTP, SMTP, FTP
XML Messaging: This layer is responsible for encoding messages in a common XML f
ormat so that messages can be understood at either end. Currently, this includes
XML-RPC and SOAP.
Service Description: This layer is responsible for describing the public interfa
ce to a specific Web service. Currently, service description is handled via the
WSDL
Service Discovery: This layer is responsible for centralizing services into a co
mmon registry, and providing easy publish/find functionality. Currently, service
discovery is handled via the UDDI.
XML-RPC is a protocol that uses XML messages to perform Remote Procedure Calls.
Requests are encoded in XML and sent via HTTP POST; XML responses are embedded i
n the body of the HTTP response.
Example (XML-RPC)
=================
<methodCall>
<methodName>weather.getWeather</methodName>
<params>
<param><value>10016</value></param>
</params>
</methodCall>
=========================
<methodResponse>
<params>
<param>
<value><int>65</int></value>
</param>
</params>
</methodResponse>
==========================
Example SOAP

=============
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getWeather
xmlns:ns1="urn:examples:weatherservice"
SOAP-ENV:encodingStyle=" http://www.w3.org/2001/09/soap-encoding
<zipcode xsi:type="xsd:string">10016</zipcode>
</ns1:getWeather>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
==========================
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getWeatherResponse
xmlns:ns1="urn:examples:weatherservice"
SOAP-ENV:encodingStyle="http://www.w3.org/2001/09/soap-encoding">
<return xsi:type="xsd:int">65</return>
</ns1:getWeatherResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
===========================
WSDL Example
=============
In a nutshell, WSDL is an XML grammar for specifying a public interface for a We
b service.
Contains information on all publicly available functions.
Data type information for all XML messages.
Binding information about the specific transport protocol to be used.
Address information for locating the specified service.
============================
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="WeatherService"
targetNamespace="http://www.ecerami.com/wsdl/WeatherService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.ecerami.com/wsdl/WeatherService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="getWeatherRequest">
<part name="zipcode" type="xsd:string"/>
</message>
<message name="getWeatherResponse">
<part name="temperature" type="xsd:int"/>
</message>
<portType name="Weather_PortType">
<operation name="getWeather">

<input message="tns:getWeatherRequest"/>
<output message="tns:getWeatherResponse"/>
</operation>
</portType>
<binding name="Weather_Binding" type="tns:Weather_PortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getWeather">
<soap:operation soapAction=""/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:weatherservice"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:weatherservice"
use="encoded"/>
</output>
</operation>
</binding>
<service name="Weather_Service">
<documentation>WSDL File for Weather Service</documentation>
<port binding="tns:Weather_Binding" name="Weather_Port">
<soap:address
location="http://localhost:8080/soap/servlet/rpcrouter"/>
</port>
</service>
</definitions>
================
UDDI
====
First, UDDI is a technical specification for building a distributed directory of
businesses and Web services. Data is stored within a specific XML format, and t
he UDDI specification includes API details for searching existing data and publi
shing new data.
Second, the UDDI Business Registry is a fully operational implementation of the
UDDI specification. The UDDI registry now enables anyone to search existing UDDI
data. It also enables any company to register themselves and their services.
The data captured within UDDI is divided into three main categories:
White Pages: This includes general information about a specific company. For exa
mple, business name, business description, and address.
Yellow Pages: This includes general classification data for either the company o
r the service offered. For example, this data may include industry, product, or
geographic codes based on standard taxonomies.
Green Pages: This includes technical information about a Web service. Generally,
this includes a pointer to an external specification, and an address for invoki
ng the Web service.

==================================================================
List searchResult = (List) request.getAttribute("searchResult");
for(Iterator itr = searchResult.iterator(); itr.hasNext();) {
roseindia.net.dao.hibernate.Tutorial tutorial =(roseindia.net.dao.hibernate.
Tutorial)itr.next();
}
class Test{
public static void main(String[] args)throws Exception{
for(int i=0;i<args.length;i++){
System.out.println(s);
}
A class with static members is known as a static class. In such cases, before a
class instance is created, an object of its class will also be created by the JV
M. The class object is allocated to the heap itself. The primordial class loader
will load the class object.
memory leaks
what is major concepts in oops.
ans:Abstraction,polymorphism,encapsulation,inheritance
48.what is implicit object.
ans:Implicit objects are a set of Java objects that the JSP Container makes avai
lable to developers in each page
49.how many implicit objects in jsp
ans:out,page,session,request,response,application,page context,config
-------------------------HOW STRUTS WORK
--------------A client requests a path that matches the Action URI pattern.
The container passes the request to the ActionServlet.
The ActionServlet selects the appropriate module,looks up the mapping for the pa
th, the mapping specifies a form bean, the ActionServlet creates one after valid
ation.If a form bean is there, the ActionServlet resets and populates it from th
e HTTP request.
If the mapping has the validate property set to true, it calls validate on the f
orm bean.
If it fails, the servlet forwards to the path specified by the input pro
perty and this control flow ends.
If the mapping specifies an Action type, it is reused if it already exists or in
stantiated.
The Action s execute method is called and passed the instantiated form bean (or nu
ll).
The Action may populate the form bean, call business objects, and do whatever el
se is needed.

The Action returns an ActionForward to the ActionServlet.


If the ActionForward is to another Action URI, we begin again; otherwise, it s off
to a display page or some other resource.
Most often, it is a JSP, in which case Jasper, or the equivalent (not Struts), r
enders the page.
struts-config.xml and This file's structure is described by the struts-config DT
D
----------------------------------------------------------------------------------<data-sources/> set of data-source elements, describing parameters needed to in
stantiate JDBC 2.0 Standard Extension DataSource objects
<form- beans/>, A set of form-bean elements that describe the form beans that th
is application uses
<global- forwards/> , A set of forward elements describing general available for
ward URIs
<actionmappings/>, A set of action elements describing a request-to-action mappi
ng
<exception/>,
<message-resources>,
<switch-action>
<plug-in/>
Tokens are used to invalidate duplicate submission
==================================================
When request posted, call Action.saveToken(HttpServletRequest).during post call
Action.isValidToken(HttpServletRequest, true) and then checks the isValidToken()
for succeding post.
-------------------------web.xml is used for making connection between web container & web application. w
eb.xml will be read by container when we start the container.
-------------------------Action.clearErrors(session, null);
------------------------------------JSP Questions
HTTP Session never times out
HttpSession session = request.getSession(true);session.setMaxInactiveInterval(-1
);
Storing ArrayList in session
===============================
ArrayList name is custNameList means;
session.setAttribute("Id",custNameList); //to store the arraylist into session.
ArrayList customerName=(ArrayList) session.getAttrinute("Id");// get the arrayli
st from session.
---------------------------------Struts-validator

---------------Element: Attributes and Description


form-validation: This is the root node. It contains nested elements for all of t
he other configuration settings
global: The constant details are specified in <constant> element within this ele
ment.
constant: Constant properties are specified within this element for pattern matc
hing.
constant-name:Name of the constant property is specified here
constant-value: Value of the constant property is specified here.
formset: This element contains multiple <form> elements
form: This element contains the form details.
The attributes are:
name:Contains the form name. Validator uses this logical name to map the validat
ions to a Form Bean defined in the struts-config.xml file
field:This element is inside the form element, and it defines the validations to
apply to specified Form Bean fields.
The attributes are: property: Contains the name of a field in the specified Form
Bean
depends: Specifies the logical names of validation routines from the validator-r
ules.xml file that should be applied to the field.
arg: A key for the error message to be thrown incase the validation fails, is sp
ecified here
var: Contains the variable names and their values as nested elements within this
element.
var-name: The name of the criteria against which a field is validated is specifi
ed here as a variable
var-value: The value of the field is specified here

What are the different advice types in spring?


Around : Intercepts the calls to the target method
Before : This is called before the target method is invoked
After : This is called after the target method is returned
Throws : This is called when the target method throws and exception
Around : org.aopalliance.intercept.MethodInterceptor
Before : org.springframework.aop.BeforeAdvice
After : org.springframework.aop.AfterReturningAdvice
Throws : org.springframework.aop.ThrowsAdvice

DataAccessException - org.springframework.dao.DataAccessException

Das könnte Ihnen auch gefallen