java.lang.UnsupportedClassVersionError: test_hello_world :
 Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)

Why this Happens?
When you did maven build in Java 8 and try to deploy the ear file in Server which uses Java 1.7 then this issue happens.Error means you’re trying to load a Java “class” file that was compiled with a newer version of Java than you have installed.For example, your .class file could have been compiled for JDK 7, and you’re trying to run it with JDK 6.You must have compiled your code with a higher version and trying to run it using a lower version

Solution

Window -> Preferences -> Java -> Compiler and then set "Compiler compliance level" to 1.7

SOAP(Simple Object Access Protocol) – SOAP is an XML-based protocol that lets you exchange info over a particular protocol (can be HTTP or SMTP, for example) between applications. It stands for Simple Object Access Protocol and uses XML for its messaging format to relay the information.

WSDL(Web Services Definition Language) – A WSDL is an XML document that describes a web service. WSDL tells about the functions that you can implement or exposed to the client. For example: add, delete, subtract, and so on. what is the service called, which methods does it offer, what kind of in parameters and return values do these methods have?

XSD(XML Schema Definition) – describes the static structure of the complex data types being exchanged by those service methods. It describes the types, their fields, any restriction on those fields (like max length or a regex pattern), and so forth.It’s a description of datatypes and thus static properties of the service – it’s about data.

XSD definitions are part of WSDL in the tag

UDDI(Universal Description, Discovery, and Integration)– It is directly that is used to publish and discover public web services. UDDI is an obsolete failure that is almost never used in practice.UDDI works just like a telephone directory where a business can be registered as per its name, geography and the web services it publishes.UDDI registers the WSDL address URL of a web service. A client of the web service searches and finds the WSDL in the UDDI registry. Once received the WSDL can be invoked by using the URL.

WSDL: When we go to a restaurant we see the Menu Items, those are the WSDL’s.
Proxy Classes: Now after seeing the Menu Items we make up our Mind (Process our mind on what to order): So, basically we make Proxy classes based on WSDL Document.
SOAP: Then when we actually order the food based on the Menu’s: Meaning we use proxy classes to call upon the service methods which is done using SOAP

SEI(service endpoint interface): The endpoint is a connection point where HTML files or active server pages are exposed. A web service endpoint is a URL that another program would use to communicate with your program. To see the WSDL, you add WSDL to the web service endpoint URL.

Parts of WSDL
Definitions – variables – ex: myVar, x, y, etc.

Types – data types – ex: int, double, String, myObjectType

Operations – methods/functions – ex: myMethod(), myFunction(), etc.

Messages – method/function input parameters & return types

ex: public myObjectType myMethod(String myVar)
Porttypes – classes (i.e. they are a container for operations) – ex: MyClass{}, etc.

Example of a Endpoint URL

protocol://host:port/partOfThePath

where

host=someIp
port=8080
partOfThePath=/some/service/path

serviceAEndpoint=http://host:port/some/service/path?dynamicParam=

Simple SOAP Request and Response

 package com.mugil.org;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebService;

@WebService
public class Products 
{
  List<String> arrProducts = new ArrayList<String>();
	
  public Products()
  {
	arrProducts.add("Books");
	arrProducts.add("EReader");
	arrProducts.add("PDF");	
  }
  
  public String getProduct(int index)
  {
	return arrProducts.get(index);  
  }
}

SOAP Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:org="http://org.mugil.com/">
   <soapenv:Header/>
   <soapenv:Body>
 
      <org:getProduct>
         <arg0>0</arg0>
      </org:getProduct>
   </soapenv:Body>
</soapenv:Envelope>

SOAP Request

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getProductResponse xmlns:ns2="http://org.mugil.com/">
         <return>Books</return>
      </ns2:getProductResponse>
   </soap:Body>
</soap:Envelope>

Part of WSDL
Typical WSDL document contains the following tags

  1. service – Contains the port which defines the Endpoint URL, port number
  2. portType – Contains input and output for an operation.Though there are multiple input and output arguments they would be bundled together as one message
  3. binding – Defines how the SOAP service could be accessed like over http,https
  4. types – Type defined as complex type defines the Input and output
  5. message – Kind of input and output taken as argument, mostly represented as Message

Service

 <wsdl:service name="ProductsService">
  <wsdl:port binding="tns:ProductsServiceSoapBinding" name="ProductsPort">
   <soap:address location="http://localhost:8096/WebService1/Products"/>
  </wsdl:port>
  </wsdl:service>

Porttype

 <wsdl:portType name="Products">
   <wsdl:operation name="getProduct">
    <wsdl:input message="tns:getProduct" name="getProduct"></wsdl:input>
    <wsdl:output message="tns:getProductResponse" name="getProductResponse"></wsdl:output>
   </wsdl:operation>
  </wsdl:portType>

Binding

<wsdl:binding name="ProductsServiceSoapBinding" type="tns:Products">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
      <wsdl:operation name="getProduct">
         <soap:operation soapAction="" style="document" />
         <wsdl:input name="getProduct">
            <soap:body use="literal" />
         </wsdl:input>
         <wsdl:output name="getProductResponse">
            <soap:body use="literal" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>

Types

 <wsdl:types>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://org.mugil.com/" version="1.0">
         <xs:element name="getProduct" type="tns:getProduct" />
         <xs:element name="getProductResponse" type="tns:getProductResponse" />
         <xs:complexType name="getProduct">
            <xs:sequence>
               <xs:element name="arg0" type="xs:int" />
            </xs:sequence>
         </xs:complexType>
         <xs:complexType name="getProductResponse">
            <xs:sequence>
               <xs:element minOccurs="0" name="return" type="xs:string" />
            </xs:sequence>
         </xs:complexType>
      </xs:schema>

Message

 <wsdl:message name="getProduct">
      <wsdl:part element="tns:getProduct" name="parameters" />
   </wsdl:message>
   <wsdl:message name="getProductResponse">
      <wsdl:part element="tns:getProductResponse" name="parameters" />
   </wsdl:message>

Service(Class name with @WebService Annotation) 
                | 
Port(has Binding which defines portType)
                | 
    PortType(defines Operations)
                | 
Operations(defines input and output Type)

Annotations for WebService

@Webservice(name="MartCatalogue", portName="MartCataloguePort", serviceName="ProductsService", targetNamespace="MartProducts.com")
.
.
@WebMethod(action="fetch_products", operationName="fetchProducts")
.

name

<wsdl:portType name="MartCatalogue">
.
.

portName and serviceName

wsdl:port binding="tns:productServiceSoapBinding" name="productPort">
  <soap:address location="http://localhost:8096/WebService1/productService"/>
</wsdl:port>
.
.

targetNamespace
Defines unique set of operations under namespace.Defaults to package name in java in reverse order
targetNamespace=”MartProducts.com”

targetNamespace

<wsdl:operation name="fetchProducts">
.
.
 <wsdl:operation name="fetchProducts">
      <soap:operation soapAction="fetch_products" style="document" />
  .
  .

String is immutable for several reasons

Design Strings are created in a special memory area in java heap known as “String Intern pool”. If the String is not immutable, changing the String with one reference will lead to the wrong value for the other references.

Security: String is widely used as parameter for many java classes, e.g. network connection, opening files, etc. Were String not immutable, a connection or file would be changed and lead to serious security threat. Mutable strings could cause security problem in Reflection too, as the parameters are strings.

Synchronization and concurrency: making String immutable automatically makes them thread safe thereby solving the synchronization issues.

Caching: Since String is immutable, its hashcode is cached at the time of creation and it doesn’t need to be calculated again. This makes it a great candidate for key in a Map and it’s processing is fast than other HashMap key objects. This is why String is mostly used Object as HashMap keys. Above are some of the reasons I could think of that shows benefits of String immutability. It’s a great feature of Java String class and makes it special.

Class loading: Strings are used in java classloader and immutability provides security that correct class is getting loaded by Classloader. For example, think of an instance where you are trying to load java.sql.Connection class but the referenced value is changed to myhacked.Connection class that can do unwanted things to your database.

substring(), concat(), replace() etc are internally use String constructor for creating new string object.

In javascript date validation, while checking selected date is less than or equal to today’s date, time should be taken into consideration otherwise even when the selected day is equal to today’s date the validation fails.

i.e

 
 var strStartDate          = $("selectedStartDate").val();
 var strStartDateFormatted = new Date(strStartDate);
 var today                 = new Date();
 
 today.setHours(12,0,0,0);

  if(strStartDateFormatted == today)
    console.log("Both are Same");

new Date() will return date with time where as date returned using the datepicker does not contain time so if you directly compare new Date() which comes along with time it would return false even when the date-month-year are equal.

Date.prototype.withoutTime = function () {
    var d = new Date(this);
    d.setHours(0, 0, 0, 0);
    return d;
}

var date1 = new Date(2014,1,1);
new Date().withoutTime() > date1.withoutTime(); // true