Saturday, June 11, 2016

Agile Methodology

The definition of agile is
Agile software development is a set of principles for software development in which requirements and solutions evolve through collaboration between self-organizing, cross-functional teams

The methods of Agile are :

Scrum : A product owner lists down the requirements which are called as backlogs. Cross functional teams lead by the Scrum Master picks up the backlog according to the priority and deliver it in successive sprints .

Lean : it focusses on
eliminations of waste.
Deciding as late as possible , delivering as early as possible.
Amplifying learning , building integrity in and seeing the whole.

Kanban : principle of kanban are :
Visualize what you have done today.
Limit the amount of work in progress.
Enhance flow.

Extreme Programming :The supporting practices of this methodology are:
Planning Game
Small Releases
Customer Acceptance Tests
Simple Design
Pair Programming
Test-Driven Development
Refactoring
Continuous Integration
Collective Code Ownership
Coding Standards
Metaphor
Sustainable Pace

References

https://www.versionone.com/agile-101/agile-methodologies/

Spring Mvc Testing

Testing Spring MVC is used to test MVC applications developed in spring.To remove the dependency of the application server and few object we need to  Mock it.The web application dependency includes servlet handler , resource handler , exception handler , view handler.
This tutorial requires minimum of Junit 4.9 , javax-servlet-api 3.0.2. You might face Spring4TestRunner exception and NoClassDefFound javax.servlet.SessionCookieConfig
If there any autowired beans in your controller class you might face an exception like IllegalState Failed to load ApplicationContext
Reference:
http://blog.zenika.com/2013/01/15/spring-mvc-test-framework/
http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-mvc-controllers-configuration/

Sunday, May 22, 2016

Hosting a SOAP Web Service Java


Step 1
Create a dynamic web project in eclipse
Create an endpoint interface
package org.myProject.passwordManager;
 import javax.jws.WebMethod;
 import javax.jws.WebService;
 @WebService public interface PasswordManagerWS {
 @WebMethod public abstract String getPassword(String appId);
 }
Create an implementation of Web Service
package org.myProject.passwordManager;
 import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding; @WebService(endpointInterface="org.myProject.passwordManager.PasswordManagerWS", serviceName="PasswordManagerWS")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT)
 public class PasswordManagerWSImpl implements PasswordManagerWS{
 @WebMethod public String getPassword(@WebParam(name="appId")String appId) { System.out.println("test ws"); return "test";
 }
 }

SOAP Web Services Java


Web Services are generally used for machine to machine communication.SOAP is a protocol for communication.

Topics

Hosting a SOAP Web Service

Monday, January 18, 2016

Proxy Class in java


What is a Proxy Class?

Proxy is a class in java which is used to create a dynamic class.

Why do we use proxy class?

links

description

Web Services Interview Questions


Web services is vast topic , lets start with creating a simple web service.I have tried explaining the concepts using a sample code ,In any point if you are unable to understand please go through the documentation links .
  • Create a sample web service as below
package org.myProject;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface TestWS {
@WebMethod
public abstract String getMethod(String param);
}
TestWS is a web service
  • Implement the web service
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService(endpointInterface="org.myProject.TestWS",serviceName="TestWS")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT)
public class TestWSImpl implements TestWS{
@WebMethod
public String getMethod(@WebParam(name="param")String param) {
System.out.println("test ws");
return "test";
}
}
In addition to implementing the method getMethod , a service name is also specified for the web service.
We have linked TestWSImpl class to TestWS using annotation param endpointInterface="org.myProject.TestWS" . Now,as we know, web service is a communication between two machines via xml messages , so an endpoint is reference to which messages are addressed.
  • Host the web service
There are several ways to host your web service.I choose to host it through jboss EAP 6.The web service need to be packaged in war file and deployed to jboss .
Service name is to be mapped in web.xml as below:
<servlet>
<servlet-name>PasswordManagerWSImpl</servlet-name>
<servlet-class>org.myProject.passwordManager.PasswordManagerWSImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PasswordManagerWSImpl</servlet-name>
<url-pattern>/TestWS</url-pattern>
</servlet-mapping>

Once the server is up and running , you can verify whether the web service is hosted properly
Go the following url
http://localhost:8089/TestWebService/TestWS?wsdl
Replace TestWebService with the name of WAR file deployed.
If on hitting the link you are able to get the WSDL then the web service is successfully hosted.
WSDL has the details of the web service which is used by the client to communicate to the web service.
  • Client Interaction with the web service
QName qName=new QName("http://myProject.org/","TestWS");
URL url=new URL("http://localhost:8089/TestWebService/TestWS?wsdl");
Service service=Service.create(url,qName);
TestWS webSer=service.getPort(TestWS.class);
String test=webSer.getMethod("test");
A QName object is created by passing namespaceURI as targetNamespace and localPost as service name from WSDL.
URL object is created by passing url of WSDL.
References:

Struts 1 Interview Question

ec2-user@ec2 Permission denied