DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

SBOMs are essential to circumventing software supply chain attacks, and they provide visibility into various software components.

Related

  • Is Enterprise Service Bus (ESB) Obsolete After Microservices?
  • Enterprise Integration Patterns From ESB to ESP and API
  • How To Get Cell Data From an Excel Spreadsheet Using APIs in Java
  • 8 Strategies To Accelerate Web Portal Development

Trending

  • Build Real-Time Analytics Applications With AWS Kinesis and Amazon Redshift
  • Squid Game: The Clean Code Trials — A Java Developer's Survival Story
  • Understanding N-Gram Language Models and Perplexity
  • Evaluating Accuracy in RAG Applications: A Guide to Automated Evaluation
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Exposing Web Services (CXF) With Mule ESB

Exposing Web Services (CXF) With Mule ESB

This article shows the steps for building and exposing web services on the CXF framework using Mule ESB, with code and a video tutorial.

By 
Jitendra Bafna user avatar
Jitendra Bafna
DZone Core CORE ·
May. 20, 17 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
24.3K Views

Join the DZone community and get the full member experience.

Join For Free

CXF is a Java web services framework used for SOAP (Simple Object Access Protocol) messaging. It handles all serialization and deserialization as well as SOAP envelope and namespace processing.

The Mule CXF module provides support for web service integration via Apache CXF. Apache CXF is an open source services framework that helps you build and develop services using frontend programming APIs, like JAX-WS.

Building a Web Service

1.) Add a new package and name it myapp.webservice.

2.) Add an interface and name it IHelloWorldService.

3.) Add a class and name it HelloWorldService. This call should implement the interface IHelloWorldService.

Make sure to add the class and interface under the folder src/main/java.

Now start defining the method in the interface and implement in class that you need to expose.

IHelloWorldService.java

package myapp.webservice;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface IHelloWorldService {
@WebMethod
 String helloWorldFunc(String name);
}

HelloWorldService.java

package myapp.webservice;
import javax.jws.WebService;

@WebService
public class HelloWorldService implements IHelloWorldService {
@Override
public String helloWorldFunc(String name) {
return "Hello World "+name;
}
}

Exposing Web Services

1.) Place the HTTP listener component in mule flow and configure it.

2.) Place the CXF component in message processor and configure it. Select the operation JAX-WS service and add service class (name of your interface i.e. myapp.webservice.IHelloWorldService).

Image title

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <cxf:configuration name="CXF_Configuration" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/>
    <flow name="cxf-webserviceFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/web" doc:name="HTTP"/>
        <cxf:jaxws-service configuration-ref="CXF_Configuration" serviceClass="myapp.webservice.IHelloWorldService" doc:name="CXF"/>
        <component class="myapp.webservice.HelloWorldService" doc:name="Java"/>
    </flow>
</mule>


3.) Place the Java component and provide the class name (i.e. myapp.webservice.HelloWorldService).

Generating the WSDL

Deploy the application and browse the url http://localhost:8081/web?wsdl.

Image title

Here is the video tutorial:


Now, you know how to expose webservice with Mule ESB.

Web Service Enterprise service bus

Opinions expressed by DZone contributors are their own.

Related

  • Is Enterprise Service Bus (ESB) Obsolete After Microservices?
  • Enterprise Integration Patterns From ESB to ESP and API
  • How To Get Cell Data From an Excel Spreadsheet Using APIs in Java
  • 8 Strategies To Accelerate Web Portal Development

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: