Foros de discusión

Simple Apache CXF web service integration

thumbnail
Uwe Vass, modificado hace 14 años.

Simple Apache CXF web service integration

New Member Mensajes: 2 Fecha de incorporación: 26/09/08 Mensajes recientes
For those who wants to use the Apache CXF web service stack instead of Axis 1.
This guide uses the ext environment and describes how to make the remote interface of a service available as web service over Apache CXF.

If you are using the ext environment just do the following things.

1) Downlad the libraries of Apache CXF. (http://cxf.apache.org)

2) Put the following libraries into the ext-lib/portal directory:
cxf-2.2.jar
FastInfoset-1.2.2.jar
geronimo-jaxws_2.1_spec-1.0.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.9.jar
jaxb-xjc-2.1.9.jar
xmlbeans-2.3.0.jar
xml-resolver-1.2.jar
XmlSchema-1.4.4.jar

3) Generate your service code with the servicebuilder. Set the remote interface to "true" in your service.xml.

4) Create a file cxf-spring.xml in ext-impl/META-INF directory with the following content:

<?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:simple="http://cxf.apache.org/simple"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<simple:server id="pojoservice"
serviceClass="com.ext.portlet.reports.service.ReportsEntryService"
serviceBean="#com.ext.portlet.reports.service.ReportsEntryService.impl"
address="/reports">
<simple:dataBinding>
<bean class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
</simple:dataBinding>
</simple:server>
</beans>

This file demonstrates how to export the ReportsEntryService interface as a web service.
Just change or add your interface and impl classes to the xml file.


5) Add the cxf-spring.xml to the portal-ext.properties. Copy the spring.config section from the portal.properties
and add the cxf-spring.xml entry. E.g.:

spring.configs=\
META-INF/base-spring.xml,\
\
META-INF/hibernate-spring.xml,\
META-INF/infrastructure-spring.xml,\
META-INF/management-spring.xml,\
\
META-INF/util-spring.xml,\
\
META-INF/jcr-spring.xml,\
META-INF/messaging-spring.xml,\
META-INF/scheduler-spring.xml,\
META-INF/search-spring.xml,\
\
META-INF/counter-spring.xml,\
META-INF/document-library-spring.xml,\
META-INF/lock-spring.xml,\
META-INF/mail-spring.xml,\
META-INF/portal-spring.xml,\
META-INF/portlet-container-spring.xml,\
META-INF/wsrp-spring.xml,\
\
META-INF/mirage-spring.xml,\
\
META-INF/ext-spring.xml,\
META-INF/cxf-spring.xml


Thats it. Build and deploy your application. After deploying your web service is available under:
http://localhost:8080/services/<service_name>
In the example above : http://localhost:8080/services/reports

WSDL is available under:
http://localhost:8080/services/<service_name>?WSDL
In the example above : http://localhost:8080/services/reports?WSDL

Can someone confirm, I didn't missed something? emoticon
Sultee khan, modificado hace 13 años.

RE: Simple Apache CXF web service integration

Regular Member Mensajes: 145 Fecha de incorporación: 31/10/09 Mensajes recientes
Hi Uwe,
Thank you very much for your instructions.. They were really helpful. ONly you forgot to mention
the servlet mappings in web.xml

<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Sultee khan, modificado hace 13 años.

RE: Simple Apache CXF web service integration

Regular Member Mensajes: 145 Fecha de incorporación: 31/10/09 Mensajes recientes
looks like friendlyURl is hindering /services/* deployment...have to check out
Sultee khan, modificado hace 13 años.

RE: Simple Apache CXF web service integration

Regular Member Mensajes: 145 Fecha de incorporación: 31/10/09 Mensajes recientes
Updated in portal-ext.properties and works fine

virtual.hosts.ignore.paths=\
    /c,\
    \
    /c/portal/change_password,\
    /c/portal/extend_session,\
    /c/portal/extend_session_confirm,\
    /c/portal/json_service,\
    /c/portal/layout,\
    /display_chart,\
    [b]/services/[/b],\
    /c/portal/login,\
    /c/portal/logout,\
    /c/portal/portlet_url,\
    /c/portal/render_portlet,\
    /c/portal/reverse_ajax,\
    /c/portal/session_tree_js_click,\
    /c/portal/status,\
    /c/portal/update_layout,\
    /c/portal/update_terms_of_use,\
    /c/portal/upload_progress_poller,\
    \
    /c/layout_configuration/templates,\
    /c/layout_management/update_page
Payam Shabaneh, modificado hace 11 años.

RE: Simple Apache CXF web service integration

New Member Mensajes: 4 Fecha de incorporación: 24/02/10 Mensajes recientes
Has anyone had success with implementing CXF on a more recent version of Liferay? ( 6.x versions ).

Issue of primary interest - https://issues.liferay.com/browse/LPS-898
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: Simple Apache CXF web service integration

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
Since the developer of Apache CXF is now with Mulesoft, it may be easier to use CXF via Mule because Mulesoft has documentation on setting up CXF at their site. (I think Mule ESB is included with liferay).
Michael Oliver, modificado hace 10 años.

RE: Simple Apache CXF web service integration

Junior Member Mensajes: 66 Fecha de incorporación: 19/04/12 Mensajes recientes
Hitoshi Ozawa:
Since the developer of Apache CXF is now with Mulesoft, it may be easier to use CXF via Mule because Mulesoft has documentation on setting up CXF at their site. (I think Mule ESB is included with liferay).


When I tried to use Mule to connect to Liferay using the CXF Client when I tried to generate the classes I got...

Rpc/encoded wsdls are not supported with CXF


Both the Liferay In Action and Mule In Action second edition do not talk about SOAP integration with Liferay and Mule.

If someone has integrated Mule with Liferay, I would sure like to know how they did it.
Michael Oliver, modificado hace 9 años.

RE: Simple Apache CXF web service integration

Junior Member Mensajes: 66 Fecha de incorporación: 19/04/12 Mensajes recientes
Hitoshi Ozawa:
Since the developer of Apache CXF is now with Mulesoft, it may be easier to use CXF via Mule because Mulesoft has documentation on setting up CXF at their site. (I think Mule ESB is included with liferay).


That would explain the dropping of the Axis code in favor of CXF, however that's not good news here, since Liferay is RPC style SOAP and CXF doesn't do RPC style.
Seyed Mohammad Hossein Jamali, modificado hace 9 años.

RE: Simple Apache CXF web service integration

Junior Member Mensajes: 77 Fecha de incorporación: 13/12/09 Mensajes recientes
Is there any complete working instruction?
How can I use CXF instead of Axis?
thumbnail
Karthik Nainupatruni, modificado hace 6 años.

RE: Simple Apache CXF web service integration

Junior Member Mensajes: 28 Fecha de incorporación: 5/05/15 Mensajes recientes
Is it really possible to generate document style instead of rpc CXF services with liferay service builder?
Kindly suggest me , if any one has done earlier.