SlideShare a Scribd company logo
Adobe CQ Integration With Apache CXF
(By Ankur Chauhan)
Introduction to Apache CXF
Generate Proxy-Classes from WSDL
Consume SOAP Webservices from CQ Applications
Demo
Goals
Why Apache CXF ?
An Open-Source Services Framework
Implements APIs like JAX-WS and JAX-RS
Speaks a variety of protocols such as SOAP, XML/HTTP,
RESTful HTTP vie HTTP, JMS etc.
Supports various WS-* web service specs
Flexible and highly configurable
Optimized for integration with Spring
To bo continued...
CXF provides prepacked OSGI bundle JARs.
cxf-bundle-minimal
Contains minimal set of CXF JARs in one single bundle
& Does not contain 3rdparty Dependencies/XML APIs
Cxf-dosgi-ri-singlebundle-distribution
Contains minimal set of CXF JARs in one single bundle, Contains all
3rdparty Dependencies and XML APIs, Contains a lot of additional JARs like
Spring, Jetty, PAX, cxf-dosgi, slf4j, Commons Logging, log4j, jdom etc.
For more info visit - http://cxf.apache.org/docs/why-cxf.html
WebService
http://www.webservicex.net/ConvertTemperature.asmx
WSDL Location
http://www.webservicex.net/ConvertTemperature.asmx?WSDL
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.6.2</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<wsdlRoot>${basedir}/src/main/wsdl</wsdlRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/CT.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Generate Proxy classes from WSDL
Factory Class
public static <T> T create(Class<T> ParentClass, String portUrl) {
return JaxWsClientFactory.create(ParentClass, portUrl, null, null);
}
public static <T> T create(Class<T> ParentClass, String portUrl, String userName, String password) {
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
try {
jaxWsProxyFactoryBean.setServiceClass(ParentClass);
jaxWsProxyFactoryBean.setAddress(portUrl);
jaxWsProxyFactoryBean.setUsername(userName);
jaxWsProxyFactoryBean.setPassword(password);
} catch (Exception e) {
e.printStackTrace();
}
return (T) jaxWsProxyFactoryBean.create();
}
Service Interface
public interface ConvertTemperatureService {
double convertCelsiusToFahrenheit(double temperatureInCelsius);
}
@Override
public double convertCelsiusToFahrenheit(double valueToConvert) {
double convertedTemperature = 0.0;
try {
convertTemperatureSoap = JaxWsClientFactory.create(ConvertTemperatureSoap.class,
"http://www.webservicex.net/ConvertTemperature.asmx");
convertedTemperature = convertTemperatureSoap.convertTemp(valueToConvert,
TemperatureUnit.DEGREE_CELSIUS, TemperatureUnit.DEGREE_FAHRENHEIT);
} catch (Exception e) {
e.printStackTrace();
}
return convertedTemperature;
}
Caused by: javax.xml.bind.JAXBException
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
... 75 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
at
org.apache.sling.commons.classloader.impl.ClassLoaderFacade.loadClass(ClassLoaderFacade.java:127)
at java.lang.ClassLoader.loadClass(Unknown Source)
at javax.xml.bind.ContextFinder.safeLoadClass(Unknown Source)
... 82 more
Reason: Illegal class loading in OSGI context
Referenced library calls
currentThread.getContextClassLoader().loadClass. In this case it‘s not CXF,
but the JAXB implementation. We cannot fix the 3rdparty Implementation.
“By default, the Thread context class loader is not aware of OSGi and
thus doesn't see any of the classes imported in the bundle. That's why loading
the class fails”.
Solution
See CQ5 KB Article:
http://helpx.adobe.com/experience-manager/kb/OsgiClassLoading3Party.html
Solution
public static <T> T create(Class<T> ParentClass, String portUrl) {
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(BusFactory.class.getClassLoader());
try {
return JaxWsClientFactory.create(ParentClass, portUrl, null, null);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}
DEMO
Questions???????
cq_cxf_integration

More Related Content

What's hot

Working with web_services
Working with web_servicesWorking with web_services
Working with web_servicesLorna Mitchell
 
LibreSSL, one year later
LibreSSL, one year laterLibreSSL, one year later
LibreSSL, one year later
Giovanni Bechis
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
Narendra Sisodiya
 
Mule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converterMule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converter
Raffaela Vitiello
 
Posh Devcon2009
Posh Devcon2009Posh Devcon2009
Posh Devcon2009
db82407
 
Apache FTP Server Integration
Apache FTP Server IntegrationApache FTP Server Integration
Apache FTP Server Integration
WO Community
 
JAVA NIO
JAVA NIOJAVA NIO
JAVA NIO
오석 한
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
Chandan Kumar Rana
 
Foomo / Zugspitze Presentation
Foomo / Zugspitze PresentationFoomo / Zugspitze Presentation
Foomo / Zugspitze Presentation
weareinteractive
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
ciklum_ods
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikar
GauravRaikar3
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with netty
Zauber
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12
N Masahiro
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
Daniel Costa Gimenes
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
adil raja
 
Netty: asynchronous data transfer
Netty: asynchronous data transferNetty: asynchronous data transfer
Netty: asynchronous data transfer
Victor Cherkassky
 
ATS Internals
ATS InternalsATS Internals
ATS Internals
Chao Xu
 
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R AugeHTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
mfrancis
 

What's hot (20)

Working with web_services
Working with web_servicesWorking with web_services
Working with web_services
 
LibreSSL, one year later
LibreSSL, one year laterLibreSSL, one year later
LibreSSL, one year later
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
Mule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converterMule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converter
 
Posh Devcon2009
Posh Devcon2009Posh Devcon2009
Posh Devcon2009
 
Apache FTP Server Integration
Apache FTP Server IntegrationApache FTP Server Integration
Apache FTP Server Integration
 
JAVA NIO
JAVA NIOJAVA NIO
JAVA NIO
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Foomo / Zugspitze Presentation
Foomo / Zugspitze PresentationFoomo / Zugspitze Presentation
Foomo / Zugspitze Presentation
 
Codigo java
Codigo javaCodigo java
Codigo java
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikar
 
Non blocking io with netty
Non blocking io with nettyNon blocking io with netty
Non blocking io with netty
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
 
Netty: asynchronous data transfer
Netty: asynchronous data transferNetty: asynchronous data transfer
Netty: asynchronous data transfer
 
ATS Internals
ATS InternalsATS Internals
ATS Internals
 
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R AugeHTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
 
unix-OS-Lab-4.doc
unix-OS-Lab-4.docunix-OS-Lab-4.doc
unix-OS-Lab-4.doc
 

Similar to cq_cxf_integration

Jax ws
Jax wsJax ws
Jax ws
F K
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationAjax Experience 2009
 
Rich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFXRich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFX
Max Katz
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
Carol McDonald
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Javaelliando dias
 
Web services in java
Web services in javaWeb services in java
Web services in java
maabujji
 
Ajax
AjaxAjax
Ajax
Yoga Raja
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
Adobe
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
Carsten Ziegeler
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
mfrancis
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
Oleg Podsechin
 
NodeJS
NodeJSNodeJS
NodeJS
Alok Guha
 
DataFX - JavaOne 2013
DataFX - JavaOne 2013DataFX - JavaOne 2013
DataFX - JavaOne 2013
Hendrik Ebbers
 
Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5
IndicThreads
 
Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0
Saltmarch Media
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQuery
William Candillon
 
WF 4.0 Overview
WF 4.0 OverviewWF 4.0 Overview
WF 4.0 Overview
dannicola
 

Similar to cq_cxf_integration (20)

Jax ws
Jax wsJax ws
Jax ws
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
 
Rich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFXRich Enterprise Applications with JavaFX
Rich Enterprise Applications with JavaFX
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
REST made simple with Java
REST made simple with JavaREST made simple with Java
REST made simple with Java
 
Web services in java
Web services in javaWeb services in java
Web services in java
 
Ajax
AjaxAjax
Ajax
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
NodeJS
NodeJSNodeJS
NodeJS
 
DataFX - JavaOne 2013
DataFX - JavaOne 2013DataFX - JavaOne 2013
DataFX - JavaOne 2013
 
Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5Indic threads pune12-java ee 7 platformsimplification html5
Indic threads pune12-java ee 7 platformsimplification html5
 
Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQuery
 
SCDJWS 5. JAX-WS
SCDJWS 5. JAX-WSSCDJWS 5. JAX-WS
SCDJWS 5. JAX-WS
 
WF 4.0 Overview
WF 4.0 OverviewWF 4.0 Overview
WF 4.0 Overview
 

cq_cxf_integration