I'm still new to Spring Integration and I've few question.
I have a service with WSDL deploy in tomcat server.
and I would like to send parameter from my spring integration flow to that service and receive
response back to do next things in the flow.
I should use outbound WS gateway to do this right?
and how to config the xml to do this?
i've try temperature example but still don't understand it.
thank you.
///////////////////////////////////////////////////////////////
Here is my config:
<int:gateway service-interface="com.app.service.IRequester" id="IRequester"
default-request-channel="requestChannel"
default-reply-channel="responseChannel"
error-channel="errorChannel" >
</int:gateway>
<int:service-activator input-channel="requestChannel" id="bu1"
ref="BU1" method="bu1Method"
output-channel="buChannel">
</int:service-activator>
<int:service-activator input-channel="errorChannel"
ref="handlerError" method="errorReturnToGateway"
output-channel="responseChannel" >
</int:service-activator>
<int:router id="routingChannel" input-channel="buChannel" ref="RoutingChannel" method="routingChannel">
<int:mapping value="firstChannel" channel="channelFirst" />
<int:mapping value="otherChannel" channel="channelOther" />
</int:router>
<int:service-activator id="firstBU" input-channel="channelFirst"
ref="FirstBU" method="doSomething" output-channel="responseChannel">
</int:service-activator>
<int:service-activator id="otherBU" input-channel="channelOther"
ref="OtherBU" method="doSomething" output-channel="responseChannel">
</int:service-activator>
I need to change output channel from both firstBU and otherBU activator to call web service which is send a paremeter to that service(paremeter type is Hashmap) and receive same type response.
I don't know how to call web service by using ws:outbound-gateway.Since I have only known to call web service using java way by generate client java class and may be i'll call service in method doSomething.
In my case,Do you think which way is better?
And I still want to know how to solve this by use ws:outbound-gateway too.
thank you.
As far as it is SOAP, so you get deal with XML. And your WSDL provides you the contract - an XSD which XML should be sent to the service and which will be returned as a response.
So, your task to configure <int-ws:outbound-gateway> and provide correct XML as a message payload to the request-channel of that component.
The same is about a response: you get an XML as payload.
However, it is for simple WS Outbound Gateway. You can configure it with marshaller and send to the request-channel some domain POJO and that marshaller takes care about converting that POJO to the XML representation for the SOAP request.
Show, your config, please, and maybe we can help more with your concreate issues.
Related
I have one transformer who's output is input for one of my http:outbound-gateway and the output channel of this outbound-gateway is input for my one of activator. My requirement is to get some of data from my Transformer to my activator.
Something like below.
<int:transformer ref="jsonToXmlTransformer" input-channel="replyChannel" output-channel="someObj"/>
<http:outbound-gateway
request-channel="someObj"
expected-response-type="o.s.h.ResponseEntity"
reply-channel="replyChannel"
url="{someurl}"
http-method="POST"
extract-request-payload="true">
</http:outbound-gateway>
<int:service-activator id="expressionConverter" input-channel="replyChannel"
ref="lastActivator"/>
Dont focus on this config. I mean, I am at home and tried my best to recall my configs as office one. Nothing wrong with that. Only that I am not getting my expected data from my transformer to my last activator. Which is nothing but like an endpoint for application flow.
Consider to transfer required data in headers. Add it into headers after transformer before outbound Gateways and get it from there in the activator.
I'm trying to write a SOAP Web Service that:
accepts one request type A
maps request A to another outbound request type B
sends request B to an external SOAP service
maps the response B back to a response A object (and returns it)
I have this working when the endpoint (B) is statically configured.
But I want to be able to hit a variety of services with varying request/response types. These would probably be configured via a properties file.
Is it possible to do this in some generic/dynamic way?
Here's my spring camel XML:
<!— SOAP inbound service —>
<cxf:cxfEndpoint
id="paymentService_A"
serviceClass="#paymentServiceBean"
address="/PaymentService"/>
<!— SOAP outbound service —>
<cxf:cxfEndpoint
id=“paymentService_B"
wsdlURL="http://localhost:9080/externalpayment/ExternalPaymentService?wsdl"
serviceClass="com.yngwietiger.ExternalPayment"
address="http://localhost:9080/externalpayment/ExternalPaymentService"/>
<!— MAP from inbound SOAP request object to external SOAP request object —>
<bean id="mapAToB_RequestProcessor" class="com.yngwietiger.MyProcessor"/>
<!— MAP external SOAP response to a response for the initial/inbound SOAP request —>
<bean id="mapBToA_ResponseProcessor" class="com.yngwietiger.MyPostProcessor"/>
<camel:camelContext id="camelContext">
<camel:route>
<camel:from uri="cxf:bean:paymentService_A"/>
<camel:process ref="mapAToB_RequestProcessor"/>
<camel:to uri="cxf:bean:paymentService_B"/>
<camel:process ref="mapBToA_ResponseProcessor"/>
</camel:route>
</camel:camelContext>
Obviously, I'm using Camel's cxfEndpoint bean. But I don't see any way to set the address, wsdlURL, etc for each request. Is that possible?
Or am I going to have to build a route for each type? If so, how do I build one of these cxfEndpoints dynamically?
Would using Spring's WS Template be more flexible?
Is there a better way that I should be doing this?
Thanks in advance.
Camel Recipient List would better fit into your requirement. This is the link, http://camel.apache.org/recipient-list.html. You have to generate the dynamic endpoint and set into the header somewhere in the route and call the recipient list.
I think you can use HTTP endpoint for your outbound message.
As it is done in the example here
I have the following simplified spring integration flow:
int-ws:inbound-gateway ----> int:transformer ----> int-kafka:outbound-channel-adapter
Basically:
A web service endpoint is exposed using the int-ws:inbound-gateway
Messages from this endpoint are put onto the input channel (the first --->)
A custom transformer translates the payload JSON format and adds the MESSAGE_KEY header (required for kafka)
The message is placed onto the inputToKafka channel (the second --->)
The int-kafka:outbound-channel-adapter pushes the message to a kafka topic
The web service operation has a request and a response payload.
The request payload is what I'm transforming into the JSON message.
I would like to return a response payload (which will be marshalled etc) once the message is placed on the kafka topic by the int-kafka:outbound-channel-adapter
How do I do this?
At the moment, when I invoke the web service everything works as expected, but I have to set a reply-timeout on the int-ws:inbound-gateway so that it doesn't hang. When I do this, I simply get an empty response back on SOAPUI.
I understand the concepts in the section Gateway behavior when no response arrives - but in my case I do want to generate a response.
This is my integration context (without the kafka broker config etc):
<int-ws:inbound-gateway id="ws-inbound-gateway" request-channel="input"
marshaller="marshaller" unmarshaller="marshaller" reply-timeout="100"/>
<int:channel id="input"/>
<int:transformer input-channel="input" output-channel="inputToKafka" method="transform">
<bean class="com.test.InputToJSONTransformer"/>
</int:transformer>
<int:channel id="inputToKafka"/>
<int-kafka:outbound-channel-adapter kafka-producer-context-ref="kafkaProducerContext"
auto-startup="true"
channel="inputToKafka"
order="1">
</int-kafka:outbound-channel-adapter>
Change
<int:channel id="inputToKafka"/>
to
<int:publish-subscribe-channel id="inputToKafka"/>
Add a second subscriber to the channel.
<service-activator input-channel="inputToKafka" ... order="2" />
Where the service generates the response; it will be invoked after a successful send to kafka.
Do not include an output-channel; the framework will take care of routing the service output back to the ws gateway.
What kind of a response are you expecting from Kafka outbound channel adapter, remember it is Adapter not a Gateway
You could however introduce another component, ServiceActivator With an input channel sendToInputToKafka now your transformer will output to this channel.
Your 'ServiceActivator' should have an #Autowire MessageChannel inputToKafka and should manually send a message to this channel programmatically.
After sending that message, you will construct your desired response as a return type of the ServiceActivator and a response to your ws gateway
I am working in spring integration soap web service module for my project requirement. In my project if soap request does not find endpoint then there is a need to send soap fault message like "Invalid endpoint", for example if end point to access my service is http://www.mycomp.com/mychannel in request but user sends in request http://www.mycomp.com/myproject, here I want to send response as "invalid endpoint" soap fault.How can I achieve this in spring integration.
please find below ws-conf.xml
<context:component-scan base-package="com.mycomp.mychannel" />
<context:spring-configured/>
<context:annotation-config/>
<import resource="classpath:/WEB-INF/soap/config/g-config.xml" />
<!-- this is used for the endpoint mapping for soap request -->
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" />
Thanks in advance.
Your question isn't valid or isn't full. Or I just don't understand you.
Actually MessageDispatcherServlet (Spring WS) just delegates request to the SoapMessageDispatcher, which ends up with NoEndpointFoundException, if there is no Endpoint with the provided path in Request.
And that Exception will be treated as SOAPFault with the faultMessage like No endpoint can be found for request ....
So, be more specific, please. Looks like Spring WS already has all required features.
I'm working on abstracting out any sort of messaging framework for some code I'm working on. Basically, I'm using a combination of Spring AOP and Spring Integration to generate messages without the Java code knowing anything about RabbitMQ, JMS, or even Spring Integration. That said, what I'm using to generate the messages is contained in its own .jar, and it re-used by several other areas of the application. I currently have the messaging system set up such that the channels on which messages are sent are specified by the code that calls the system (i.e., channels are generated automatically based on the external method invocation) by specifying the channel name in the message header and using a header-value router to create the channels if they don't exist. My issue comes in on the endpoint of these channels - the intention of the current structure is to allow Spring to change to any messaging structure as requirements specify or change. I know how to take a static channel and use outbound channel converters/gateways to send it to a pre-specified RabbitMQ/JMS queue and process from there; what I'm struggling with is how to tell Spring that I need every channel created by the router to have a RabbitMQ (or whatever other messaging system gets implemented) outbound channel adapter that's dynamically generated based on the channel name since we don't know channel names beforehand.
Is this possible? And if not, would you mind providing input as to what could perhaps be a better way?
Thanks ahead of time!
Here's a basic template of what my config file looks like - I have an initial channel ("messageChannel") which gets sent to a publish-subscribe-channel and queuing channel depending on one of the message headers and is routed from there.
<!--Header value based channel configurations-->
<int:channel id="messageChannel" />
<int:channel id="queue" />
<int:publish-subscribe-channel id="topic" />
<!--Header-based router to route to queue or topic channels-->
<int:header-value-router input-channel="messageChannel"
header-name="#{ T(some.class.with.StringConstants).CHANNEL_TYPE}" />
<!--Re-routes messages according to their destination and messaging type-->
<int:header-value-router input-channel="queue"
header-name="#{ T(some.class.with.StringConstants).MESSAGE_DESTINATION}" />
<int:header-value-router input-channel="topic"
header-name="#{ T(some.class.with.StringConstants).MESSAGE_DESTINATION}" />
<!--AOP configuration - picks up on any invocation of some.class.which.generates.Messages.generateMessage()
from a Spring-managed context.-->
<aop:config>
<aop:pointcut id="eventPointcut"
expression="execution(* some.class.which.generates.Messages.generateMessage(..))" />
<aop:advisor advice-ref="interceptor" pointcut-ref="eventPointcut"/>
</aop:config>
<int:publishing-interceptor id="interceptor" default-channel="messageChannel">
<int:method pattern="generateMessage" payload="#return" channel="messageChannel" />
</int:publishing-interceptor>
See the dynamic-ftp sample; it uses a dynamic router that creates new outbound endpoints/channels on demand.