What are the differences between SOAP WS and RESTful WS?


SOAP Web Services RESTfull Web Services
The SOAP WS supports both remote procedure call (i.e. RPC) and message oriented middle-ware (MOM) integration styles. The Restful Web Service supports only RPC integration style.
The SOAP WS is transport protocol neutral. Supports multiple protocols like HTTP(S),  Messaging, TCP, UDP SMTP, etc. The REST is transport protocol specific. Supports only HTTP or HTTPS protocols.
The SOAP WS permits only XML data format. You define operations, which tunnels through the POST. The focus is on accessing the named operations and exposing the application logic as a service. The REST permits multiple data formats like XML, JSON data, text, HTML, etc. Any browser can be used because the REST approach uses the standard GET, PUT, POST, and DELETE Web operations. The focus is on accessing the named resources and exposing the data as a service. REST has AJAX support. It can use the XMLHttpRequest object. Good for stateless CRUD (Create, Read, Update, and Delete) operations.GET – represent()POST – acceptRepresention()

PUT – storeRepresention()

DELETE – removeRepresention()

SOAP based reads cannot be cached. REST based reads can be cached. Performs and scales better.
SOAP WS supports both SSL security and WS-security, which adds some enterprise security features like maintaining security right up to the point where it is needed, maintaining identities through intermediaries and not just point to point SSL only, securing different parts of the message with different security algorithms, etc. The REST supports only point-to-point SSL security. The SSL encrypts the whole message, whether all of it is sensitive or not.
The SOAP has comprehensive support for both ACID based transaction management for short-lived transactions and compensation based transaction management for long-running transactions. It also supports two-phase commit across distributed resources. The REST supports transactions, but it is neither ACID compliant nor can provide two phase commit across distributed transactional resources as it is limited by its HTTP protocol.
The SOAP has success or retries logic built in and provides end-to-end reliability even through SOAP intermediaries. REST does not have a standard messaging system, and expects clients invoking the service to deal with communication failures by retrying.

 

Other Useful links:

 Click here to know more about webservices

Click here to know more about RESTfull web services.

Click here for Web services Question and Answers.

Click here to know how to create a SOAP web service.

Click here to know how to write web service client suing java.

What are the differences between DispatchAction and LookupDispatchAction in Struts Framework?


Dispatch Action
LookupDispatchAction
 
It’s a parent class of  LookupDispatchAction
Subclass of Dispatch Action
DispatchAction provides a mechanism for grouping a set of related functions into asingle action, thus eliminating the need to create separate actions for each function.
An abstract Action that dispatches to the subclass mapped executes method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the parameter property of the corresponding ActionMapping.
If not using Internalization functionality then dispatch action is more useful.
 
Lookup Dispatch Action is useful when we are using Internalization functionality
 
DispatchAction selects the method to execute depending on the request parameter valuewhich is configured in the xml file.
LookupDispatchAction looks into the resource bundle file and find out the corresponding key name. We can map this key name to a method name by overriding the getKeyMethodMap() method. 
DispatchAction is not useful for I18N
 
LookupDispatchAction is used for I18N
 
Find the DispatchAction Example here
Others Posts:

Replace special characters in a String using java


package in.javatutorials;

/**
* @author javatutorials
* @since version 1.0
*
* Below class replaces the special characters in a string with empty value
*
*/
public class ReplaceSpecialCharacters {

public static final String REG_EXPR = “[!\”#$%&'()*+-./:;<=>?@\\^_{|}~`,.\\[\\]]*”;

/**
* @param args
*/
public static void main(String[] args){
String str = “a – b +c^d!e+f g . h (Pvt) Ltd.”;
//Create class object and call replace special characters method
ReplaceSpecialCharacters rsc = new ReplaceSpecialCharacters();
String afterReplacing = rsc.replaceSpecialChars(str);
System.out.println(“After replacing special characters : “+afterReplacing);
}

/**
* @param string String
* @return string String
*/
public String replaceSpecialChars(String string){
string = string.replaceAll(REG_EXPR, “”);
while(string.indexOf(” “) != -1){
string = string.replaceAll(” “, ” “);
}

return string;
}

}