Spring Integration Web Service 405 Error - spring-integration

I've been asked to do a prototype, converting a working web service that uses a Spring enabled JAX-WS endpoint to using Spring Integration instead, and I've been told to use xml configuration as much as possible. I stripped down the application until just the relevant web service elements remain, and I've created a couple of new spring xml config files as needed. While it compiles fine, when I deploy to a JBoss container and then try to invoke it using SoapUI, I get a HTTP 405 response, and there's nothing in the JBoss console to indicate that the request was even received, though the server log indicates the new gateway and service activator was setup correctly and is running. I can't find anything remotely relevant in any of the Spring documentation I've read, and none of the code examples I've pulled from Github address configuring the web service to run in an actual J2EE server.
I'm at a complete loss as to what I should be looking at. Here are my spring config files:
springContext-main.xml (I can't use applicationContext.xml in the real app due to pre-existing contraints)
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<!-- <bean class="com.bofa.ecom.intfacade.web.ApplicationConfiguration"/> -->
<bean id="reconDao" class="com.bofa.ecom.intfacade.snf.recon.dao.ReconDAOImpl">
<!-- <property name="dataSource" ref="dataSource"/> -->
</bean>
<bean id="reconServiceHelper" class="com.bofa.ecom.intfacade.snf.recon.service.helper.ReconServiceHelperImpl">
<constructor-arg ref="reconDao"/>
</bean>
<import resource="classpath:/META-INF/spring/recon-ws.xml"/>
</beans>
recon-ws.xml
<?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:util="http://www.springframework.org/schema/util"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd">
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
<import resource="classpath:/META-INF/spring/inbound-gateway-config.xml" />
<sws:dynamic-wsdl id="reconWsdl" portTypeName="reconGateway" locationUri="/reconService"
targetNamespace="http://intfacade.cpm.ecom.bofa.com/">
<sws:xsd location="/WEB-INF/recon.xsd"/>
</sws:dynamic-wsdl>
<bean
class="org.springframework.ws.server.endpoint.mapping.UriEndpointMapping">
<property name="defaultEndpoint" ref="reconGateway"></property>
</bean>
</beans>
inbound-gateway-config.xml
<?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-ws="http://www.springframework.org/schema/integration/ws"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<int:channel id="recon-input"/>
<int-ws:inbound-gateway id="reconGateway" request-channel="recon-input"/>
<int:service-activator input-channel="recon-input" method="saveArrangementApplicationDetails">
<bean id="arrangementApplicationReconService" class="com.bofa.ecom.intfacade.snf.recon.service.ArrangementApplicationReconServiceImpl">
<constructor-arg ref="reconServiceHelper"/>
</bean>
</int:service-activator>
</beans>
Any pointers in the right direction would be greatly appreciated.
Edit: I've narrowed it down to what I think is a configuration problem with either SI or Spring-ws. I can't find a complete SI + Spring-ws example that uses XML configuration to figure out what I'm missing or doing wrong. I've added my spring ws config file above.

405 is Method Not Allowed - it appears you are doing a GET (or something else) rather than a POST.
If you believe you are POSTing, take a look with a network monitor (wireshark, or the built-in tcp/ip monitor in eclipse).
You may also be hitting the wrong URL; I suggest you turn on DEBUG logging on the server.
If you still can't figure it out, post the log someplace such as a gist.

Related

spring-integration-kafka message-driven-channel-adapter XML config

I am trying to write an app to consume messages from Kafka topic and then enrich the inbound message to add new headers. The versions in use are:
spring-integration-core -- 5.3.4.RELEASE
spring-integration-kafka -- 3.3.1.RELEASE
spring-boot -- 2.3.5.RELEASE
When in my integration XML, int-kafka:message-driven-channel-adapter doesn't allow me to supply an output channel or channel property. I am not sure how to tie this to next channel in the flow which can be a router, transformer, enricher, or anything else for that matter.
This is a sample app that will just receive a message from Kafka topic, do some transformation, enrichment, etc. and then persist the parts of message in the database.
Can you please give some XML config template for a multi-channel integration?
For the sake of completion, here's what I am trying but not able to proceed further:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
xmlns:int-xml="http://www.springframework.org/schema/integration/xml"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
http://www.springframework.org/schema/integration/kafka http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<int-kafka:message-driven-channel-adapter
listener-container="messageListenerContainer"
send-timeout="5000"
mode="record"
retry-template="template"
recovery-callback="callback"
error-message-strategy="ems"
error-channel="errorChannel" />
</beans>
Are you having a runtime problem or an IDE problem?
There's a test case that has a channel property.
https://github.com/spring-projects/spring-integration/blob/15c2d16866a72470b35c65a34e869998f5823f81/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaMessageDrivenChannelAdapterParserTests-context.xml#L12-L23
I am seeing some false errors in eclipse right now; investigating...
EDIT
If you are using Spring Tool Suite 4, XML namespace support is disabled by default.
Enabling it solved the problem for me, but I had to restart the IDE.

Spring Integration http outbound-gateway

I'm trying to use the Spring Integration http outbound gateway, but I seem to be getting schema-related errors. The errors are:
cvc-complex-type.3.2.2: Attribute 'expected-response-type' is not allowed to appear in element 'int-http:outbound-gateway'. sprint-servlet.xml /sprint/src/main/webapp/WEB-INF line 28
cvc-complex-type.3.2.2: Attribute 'url' is not allowed to appear in element 'int-http:outbound-gateway'. sprint-servlet.xml /sprint/src/main/webapp/WEB-INF line 28
cvc-complex-type.3.2.2: Attribute 'http-method' is not allowed to appear in element 'int-http:outbound-gateway'. sprint-servlet.xml /sprint/src/main/webapp/WEB-INF line 28
cvc-complex-type.3.2.2: Attribute 'reply-timeout' is not allowed to appear in element 'int-http:outbound-gateway'. sprint-servlet.xml /sprint/src/main/webapp/WEB-INF line 28
It appears that the XSD does not accept these attributes. However, I've simply copy / pasted this from the Spring Integration docs. Here's the relevant part of my XML config file:
<?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:int-http="http://www.springframework.org/schema/integration/http"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- Spring Integration stuff -->
<int:channel id="requests">
</int:channel>
<int:channel id="replies"/>
<int-http:outbound-gateway id="example"
request-channel="requests"
url="http://localhost/test"
http-method="POST"
expected-response-type="java.lang.String"
charset="UTF-8"
reply-timeout="1234"
reply-channel="replies"/>
Is there something obvious that I'm doing wrong?
Thanks,
Tim
Add spring-integration-http and spring-integration-core to your dependencies.
Should work
I had the same problem and found the answer here
Why does Spring Integration have several XML schemas, and which one should I use?
Basically, the schema without a version is the version 1.0 schema. Point your schema to your version of spring integration like so
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-4.1.xsd
http://www.springframework.org/schema/integration/http
http://www.springframework.org/schema/integration/http/spring-integration-http-4.1.xsd
I'm not using STS - I'm using the standard Eclipse IDE. I'm not sure if STS helps with the classpath, but I simply can't get that to work for me. I ended up having to extract the XSDs from the .jar files and hosting them myself. Hopefully, the good folks at Spring Integration will post the most recent XSDs on the Spring site sometime soon. Until that time, however, I've got a workaround in place.

Spring webflow: How to configure Multiple Flow Executors

I am trying to configure multiple flow executors for my project as I need one set of flows with 'always-redirect-on-pause' attribute as false and another as true. I have tried searching, skimming Spring Docs but been unable to come up with this configuration. Can anyone please share these configurations and/or direct to some relevant resource?
Thanks
You can have multiple workflow (flow definition files) location registration in your project Spring Configuration file
Spring Configuration
<?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:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
<bean id="assetManagementService" />
<bean id="savingsAssetService" />
<bean id="handlerMapping">
<property name="mappings">
<value>/assetMgmtHomeView.htm=flowController</value>
</property>
</bean>
<bean id="flowController">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
</webflow:flow-executor>
<webflow:flow-registry id="flowRegistry">
<webflow:flow-location id="assetMgmtHomeView" path="/WEB-INF/flows/assetMgmtFlow.xml" />
<webflow:flow-location id="savingsAssetViewFlow" path="/WEB-INF/flows/savingsAssetViewFlow.xml" />
</webflow:flow-registry>
</beans>
As you can see webflow:flow-registry contains two workflow xml files path. Keep in mind that those location registrations have different IDs used to distinguish among the workflows.

Configuring Web Flow for use with JSF

I am trying to do Configuring Web Flow for use with JSF. from the following site
http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/ch13s04.html
but I am getting the following error:
Description Resource Path Location Type
The prefix "si" for attribute "si:schemaLocation" associated with an element type "beans" is not bound. flowwithjsf.xml /WebFlowWithJSFIntegration/src/main/webapp/WEB-INF/spring line 12 XML Problem
Here is my XML it looks just like the site:
<?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:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:faces="http://www.springframework.org/schema/faces"
si:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
http://www.springframework.org/schema/faces
http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor">
<webflow:flow-execution-listeners>
<webflow:listener ref="facesContextListener"/>
</webflow:flow-execution-listeners>
</webflow:flow-executor>
<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
<webflow:flow-location-pattern value="**/*-flow.xml" />
</webflow:flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="flowBuilderServices" />
<!-- A listener maintain one FacesContext instance per Web Flow request. -->
<bean id="facesContextListener"
class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />
</beans>
try changing si:schemaLocation="... by xsi:schemaLocation="... I think that is why you are having this error
"To use this schema, include it in one of your infrastructure-layer beans files"
10.2 Spring docs

How to integrate Spring Webflow, Spring Mobile and WURFL

I wonder if anyone can help. I am working on a Spring Webflow 2 app, where I would also like to integrate Spring Mobile 1.0 with WURFL 1.4.2.
I have got Webflow and Spring Mobile working together like this:
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="order" value="1"/>
<property name="mappings">
<value>/fnol=flowController</value>
</property>
<property name="interceptors">
<list>
<bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" />
</list>
</property>
And then within one of my action classes I can do this:
public Event startUp(RequestContext arg0) throws Exception {
// get the http request form the webflow RequestContext
ServletExternalContext externalContext = (ServletExternalContext) arg0.getExternalContext();
HttpServletRequest request = (HttpServletRequest) externalContext.getNativeRequest();
// get the Spring Mobile Device
Device currentDevice = DeviceUtils.getCurrentDevice(request);
This seems to work OK, but now I'd like to use WURFL with Spring Mobile so that I get a richer object representing the client capabilities.
This link suggests that I should be able to add a constructor to the DeviceResolverHandlerInterceptor like this:
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="order" value="1"/>
<property name="mappings">
<value>/fnol=flowController</value>
</property>
<property name="interceptors">
<list>
<bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor">
<constructor-arg>
<device:wurfl-device-resolver root-location="/WEB-INF/wurfl/wurfl.zip" />
</constructor-arg>
</bean>
</list>
</property>
And I define the device namespace as:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:device="http://www.springframework.org/schema/mobile/device"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
http://www.springframework.org/schema/mobile/device
http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd" >
As far as my IDE is concerned (Eclipse) it is happy, and it deploys to wtp no problem. But when I start wtp I get the following error:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mobile/device]
Offending resource: class path resource [fnol-webContext.xml]
Bean 'handlerMapping'
-> Property 'interceptors'
-> Bean ''
-> Constructor-arg
I'm not really sure what this means. Any ideas anyone?
Appreciate any help you guys can offer,
Cheers, Nathan
Had a look through the github repo to see if I could discern what happened: looks like WURFL support was deliberately removed due to licensing anomalies
https://github.com/SpringSource/spring-mobile/commit/ca81c6c20f1a9e524b0150e14dab20b020676e0b
This page alludes to a separate project which would provide WURFL support: I've not found it.

Resources