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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Consuming SOAP Service With Apache CXF and Spring
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • How to Consume REST Web Service (GET/POST) in Java 11 or Above
  • Breaking Up a Monolithic Database with Kong

Trending

  • Designing Frontend Applications for Failure, Not Just Success
  • Microsoft Fabric Throttling: Diagnose Before You Scale
  • Evaluating RAG in Production — What the Numbers Actually Revealed
  • AI Agents Need an Identity Plane: Rethinking Enterprise Authorization for Autonomous Software

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Exposing and Consuming SOAP Web Service Using Apache Camel-CXF Component and Spring

Exposing and Consuming SOAP Web Service Using Apache Camel-CXF Component and Spring

By 
Roshan Thomas
·
Mar. 05, 15 · Interview
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
52.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Let’s take the customer endpoint in my earlier article. Here I am going to use Apache Camel-CXF component to expose this customer endpoint as a web service.

@WebService(serviceName="customerService")
public interface CustomerService 
{
	public Customer getCustomerById(String customerId);

}

public class CustomerEndpoint implements CustomerService
{
	private CustomerEndPointService service;

	@Override
	public Customer getCustomerById(String customerId)
	{
		Customer customer= service.getCustomerById(customerId);
		return customer;
	}

	
}

Exposing the service using Camel-CXF component

<cxf:cxfEndpoint id="customerEndpoint" address="http://localhost:9000/CRMApplication/customer"
            wsdlURL="http://localhost:9000/CRMApplication/customer?wsdl"
            serviceClass="com.sample.services.customers.CustomerService"
            endpointName="ws:CustomerServicePort"
            serviceName="ws:CustomerService"
        xmlns:ws="http://com.sample.customer.endpoint" />

Remember to specify the schema Location and namespace in spring context file

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:cxf="http://camel.apache.org/schema/cxf"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

Consuming SOAP web service using Camel-CXF

Say you have a SOAP web service to the address http://localhost:8181/OrderManagement/order

Then you can invoke this web service from a camel route. Please the code snippet below.

	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
       <route>
         <from uri="cxf:customerEndpoint" />
         <to uri="http://localhost:8181/OrderManagement/order" />
       </route>
    </camelContext>

In a camel-cxf component you can also specify the data format for an endpoint like given below.

<cxf:cxfEndpoint id="customerEndpoint" address="http://localhost:9000/CRMApplication/customer"
            wsdlURL="http://localhost:9000/CRMApplication/customer?wsdl"
            serviceClass="com.sample.services.customers.CustomerService"
            endpointName="ws:CustomerServicePort"
            serviceName="ws:CustomerService"
        xmlns:ws="http://com.sample.customer.endpoint">
		<cxf:properties>
			<entry key="dataFormat" value="MESSAGE"/>
		</cxf:properties>
	</cxf:cxfEndpoint>

Hope this will help you to create SOAP web service using Camel-CXF component.

Web Service SOAP Web Protocols

Opinions expressed by DZone contributors are their own.

Related

  • Consuming SOAP Service With Apache CXF and Spring
  • Spring Boot - How To Use Native SQL Queries | Restful Web Services
  • How to Consume REST Web Service (GET/POST) in Java 11 or Above
  • Breaking Up a Monolithic Database with Kong

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook