Friday, 1 November 2013

Jackrabbit Repository jar,war download

Jackrabbit standalone-2.6.4.jar download.Click below link

http://jackrabbit.apache.org/downloads.html#v2.6

=>Use this command to create Jackrabbit repository and start that 

=>java -jar jackrabbit-standalone-2.6.4.jar -port 2629

=>We can use any port(Without conflicts to other services)

=>When we run the above command jackrabbit repository file will create,so that we can store files,and we can download files from jackrabbit.

=>To see how the files are storing into jackrabbit we can use jackrabbit explorer war file

Jackrabbit war download.Click below link

https://code.google.com/p/jackrabbitexplorer/downloads/list

=>After download this war,just deploy into any server(Tomcat or other) .

=>Access the jackrabbit explorer as follows

=>http://localhost:8080/jackrabbitexplorer/



=>Default user name and passwords are admin,admin

=>Just change port number of jackrabbit,what we assigned (2629) and login,It will open jackrabbit explorer


SOAP WebService Using Apache CXF Example with Service and Client (Bottom To Top Approach)

=>First Develope One interface.Develope your own methods.

=>These methods i want to expose as a FirstService

=>Just Create Normal Java interface with @WebService Annotation only

package com.service;

import javax.jws.WebService;

@WebService
public interface FirstService {

public String methodOne();

public int methodTwo();

}

=>Provide the implementation for Above Interface

=>Just add extra annotation @WebService(endpointInterface="com.service.FirstService")
     End point means interface name with package only

package com.service.impl;

import javax.jws.WebService;

@WebService(endpointInterface="com.service.FirstService")
public class FirstServiceImpl implements FirstService {

public FirstServiceImpl() {
System.out.println("+++++From FirstServiceImpl+++");
}

@Override
public String methodOne() {
System.out.println("+++From FirstServiceImpl methodOne()+++");
return "k fine";
}

@Override
public int methodTwo() {
System.out.println("+++From FirstServiceImpl methodTwo()+++");
return 100;
}
}


=>Add Maven Dependencies for Spring with Apache CFX

        <repositories>

        <repository>
            <id>sourceforge</id>
            <url>http://oss.sonatype.org/content/groups/sourceforge/</url>
            <releases>
                <enabled>true</enabled> 
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

<properties>
<cxf.version>2.7.2</cxf.version>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<dependencies>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- Jetty is needed if you're are not using the CXFServlet -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-addr</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
                <dependency>
  <groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
 
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
             </dependencies>

=>Web.xml

<web-app>
<context-param>
                 <param-name>contextConfigLocation</param-name>
                <param-value>WEB-INF/ApplicationContext.xml</param-value>
        </context-param>
 <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>


=>ApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:wsa="http://cxf.apache.org/ws/addressing"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/transports/http/configuration 
http://cxf.apache.org/schemas/configuration/http-conf.xsd 
http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://cxf.apache.org/jaxws
        http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="firstService" class="com.iton.FirstServiceImpl">
</bean>
<jaxws:endpoint implementorClass="com.iton.FirstServiceImpl" implementor="#firstService"                address="/firstService">
</jaxws:endpoint>
</beans>

=>Deploy the Project into the server(Tomcat or any other)

=>After deployment successfull this file will generate automatically.

=>It is the responsibility of apache cxf to identify webservice annotation and convert our java programs into wsdl file as webservice .





=> All Services exposed by us is displayed in this file,This is the WSDL file

=>WSDL : {http://iton.com/}FirstServiceImplService ,click on this link,WSDL of this service will display as follows




=>By using this url only we can generate java files(By using these java files only client can communicate with this service)

=>Copy the url(http://localhost:8090/SoapServiceExample/firstService?wsdl) and go to command prompt
     and use this command to generate java programs(or Stubs).

=>wsimport -keep -s D:\eclipseWorkspace\SOAP\SoapServiceClientExample\src      http://localhost:8090/SoapServiceExample/firstService?wsdl

=>D:\eclipseWorkspace\SOAP\SoapServiceClientExample\src. I am just telling where to copy those generate java files for client program,I am using eclipse so that i put these java files directly into my eclipse work space

=>SoapServiceClientExample is my client project for to access the services.

=>Client Program

package com.iton.client;

import com.service.FirstService;
import com.service.impl.FirstServiceImplService;


public class FirstServiceClient {

public static void main(String args[]) {
//Getting FirstServiceImplService class,In stubs automatically class extension adding with     Service
FirstServiceImplService firstServiceImplService=new FirstServiceImplService();
//From this Service class we are getting our Interface by using getFirstServiceImplPort(),in stubs our class preceeds with get and extension as Port is created automatically
FirstService firstService=firstServiceImplService.getFirstServiceImplPort();
//From interface calling methods
System.out.println("From FirstSrvice methodOne::"+firstService.methodOne());
System.out.println("From FirstSrvice methodTwo::"+firstService.methodTwo());
}
}

Output:

From FirstSrvice methodOne::k fine
From FirstSrvice methodTwo::100