:-JAX-RS:-
RestFul WebService:-
Soap send request only in soap way:-
Rest can send json,xml,any test undersand b/w client and server:-
-------------------------------------------
Soap- Need wsdl
Rest- No need and dcoc,,if in case any required then,. very less will be
--------------------------------------------------------------------------
Soap webservice has bunch of rules and it has to follow every rules if not then it's not saop webservice
Restful is a concept it's an idea no committee will tell you you need to follow this way it's not a specification
-------------------------------------------------------------------------------------------------
weather.com/lookup.action?unqiid=98990 --------> action based
Resource based url:_weather.com/lookup/zipcod/2999
it seems like data is there and we are fetching.. directly from server ,, server not doing any action ...it might doing interanlaly
but showing not doing only giving but action based it will show that it's doing
-------------------------------------------------------------
--------------------Http Methods:-
Representational state transfer
Get(idempotent) won't change state
Post
Put
Delete (Good restful API use all of it together):-
GET:--
POST requests are never cached
POST requests do not remain in the browser history
POST requests cannot be bookmarked
POST requests have no restrictions on data length
--------------------------------------------------------------------
to use POST to create resources,
use PUT to update resources.(Put is Idempotent) so no change in state.
---------------------------------------------------------------------------
--------------------------------------------------------------------
MetaData:-
http defines those things it has status codes:-
100 infrmational
200 sucess
500 servver errror
300- redirection
400 client error
--------------------
Header value contain value Content type for underatnding . the data
-------------------------
for restful:-
Resourcebased URI
choose right http method
http status codes
message header (content type)
cache mechnism only for get request ..because we are only retering data
-------------------------------------------------------------
Jersey Implementation,
Apache CXF;-
Main Annotation used in Jersey,
@Path(/your path name),ex @Path(/welcome)
@POST
@GET
@PUT
@DELETE
@PathParam, Ex-m1(@pathParam ("name") String name)
@QueryParam("name")String name-but here query is parameter like :url?name="ashish"
@Context:- instead of fetching using QueryParam fetch dirctly via context reference
@Produce("text/plain")
@FormParam("name")String name
Now while giving response from method we need to do following thing:-
p Response m1()
{
String result="any thing";
Response.status(200).entity(result).build();
}
------------------------------------------------------
We simple create the Jersey client and consume the webservices:--
http://www.programmableweb.com/apis/directory
This place we are having lots of restful webservices to consume what you need to do ,create the client for all and use them
we have below approach for creating client;-
1-Jersey
2-Httpclinet:-
Ex:-
http://alvinalexander.com/java/java-apache-httpclient-restful-client-examples
RestFul WebService:-
Soap send request only in soap way:-
Rest can send json,xml,any test undersand b/w client and server:-
-------------------------------------------
Soap- Need wsdl
Rest- No need and dcoc,,if in case any required then,. very less will be
--------------------------------------------------------------------------
Soap webservice has bunch of rules and it has to follow every rules if not then it's not saop webservice
Restful is a concept it's an idea no committee will tell you you need to follow this way it's not a specification
-------------------------------------------------------------------------------------------------
weather.com/lookup.action?unqiid=98990 --------> action based
Resource based url:_weather.com/lookup/zipcod/2999
it seems like data is there and we are fetching.. directly from server ,, server not doing any action ...it might doing interanlaly
but showing not doing only giving but action based it will show that it's doing
-------------------------------------------------------------
--------------------Http Methods:-
Representational state transfer
Get(idempotent) won't change state
Post
Put
Delete (Good restful API use all of it together):-
GET:--
- GET requests can be cached
- GET requests remain in the browser history
- GET requests can be bookmarked
- GET requests should never be used when dealing with sensitive data
- GET requests have length restrictions
- GET requests should be used only to retrieve data
Post:-
--------------------------------------------------------------------
to use POST to create resources,
use PUT to update resources.(Put is Idempotent) so no change in state.
---------------------------------------------------------------------------
--------------------------------------------------------------------
MetaData:-
http defines those things it has status codes:-
100 infrmational
200 sucess
500 servver errror
300- redirection
400 client error
--------------------
Header value contain value Content type for underatnding . the data
-------------------------
for restful:-
Resourcebased URI
choose right http method
http status codes
message header (content type)
cache mechnism only for get request ..because we are only retering data
-------------------------------------------------------------
Jersey Implementation,
Apache CXF;-
Main Annotation used in Jersey,
@Path(/your path name),ex @Path(/welcome)
@POST
@GET
@PUT
@DELETE
@PathParam, Ex-m1(@pathParam ("name") String name)
@QueryParam("name")String name-but here query is parameter like :url?name="ashish"
@Context:- instead of fetching using QueryParam fetch dirctly via context reference
@Produce("text/plain")
@FormParam("name")String name
Now while giving response from method we need to do following thing:-
p Response m1()
{
String result="any thing";
Response.status(200).entity(result).build();
}
------------------------------------------------------
We simple create the Jersey client and consume the webservices:--
http://www.programmableweb.com/apis/directory
This place we are having lots of restful webservices to consume what you need to do ,create the client for all and use them
we have below approach for creating client;-
1-Jersey
2-Httpclinet:-
Ex:-
http://alvinalexander.com/java/java-apache-httpclient-restful-client-examples
No comments:
Post a Comment