Web Services
Spring Integration provides two ways by it supports web services as follows:
- Invoking a web service by sending a message to a channel using an outbound web service gateway
- Sending a message to a channel upon receiving a web service invocation using an inbound web service gateway
Spring Integration provided inbound and outbound gateways include support for adding an XML marshaller and provides both client and server support for web services. Spring Integration builds upon the Spring Web Services project and the required Maven dependencies for the Spring Integration web services gateways are as shown in Listing 22-81 below.
Listing 22-81. Maven dependency required
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-xml</artifactId> <version>${spring-integration-version}</version> </dependency> <dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-ws</artifactId> <version>${spring-integration-version}</version> </dependency> |
Listing 22-82 below shows configuration of main Spring Integration namespace and Web Service related namespace in the Spring configuration file (ws-integration-context.xml).
Listing 22-82. Spring Integration Namespace declaration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?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:int="http://www.springframework.org/schema/integration" xmlns:ws="http://www.springframework.org/schema/integration/ws" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws-2.1.xsd"> … </beans> |
Listing 22-83 below shows configuring web service inbound gateway in the Spring configuration file. It also uses a marshaller and unmarshaller that will do the necessary marshaling and unmarshalling of the web service calls.
Listing 22-83. Configuring web service inbound gateway
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<beans …> … <int:channel id="requestChannel"/> <ws:inbound-gateway id="marshallingGateway" request-channel="requestChannel" marshaller="someMarshaller" unmarshaller="someUnmarshaller"/> … </beans> |
Listing 22-84 below shows configuring web service outbound gateway in the Spring configuration file. Similar to inbound gateway shown in the previous code snippet, it also uses a marshaller and unmarshaller that will do the necessary marshaling and unmarshalling of the web service calls.
Listing 22-84. Configuring web service outbound gateway
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<beans …> … <int:channel id="requestChannel"/> <ws:outbound-gateway id="marshallingGateway" request-channel="requestChannel" uri="http://mybook.com/sample" marshaller="someMarshaller" unmarshaller="someUnmarshaller"/> … </beans> |
Page Visitors: 13052

Tomcy John

Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023
Hi,
Thanks for this blog and information sharing!
I have one question from Spring Integration. Just thought of checking with you.
I have SimplewebserviceOutBoundGateway. I need to send a document / attachment to the webservice. How will i achieve that?
This is my current gateway configuration:
Please let me know, if you can throw some light in this area.
Thanks in Advance!
Hi,
Thank you for your information sharing.
I have one doubt,could you please suggest me the correct frameworks to address that issue.
My requirement is I would like to get and process files using spring and camel.
Thanks,
Madhu