我们希望将我们的Spring应用程序从JBoss 7.1.1迁移到WildFly 10.1。我们使用基于CXF和Spring管理的Web服务,但在WildFly 10.1上我们无法配置这些服务。
我们尝试了两种方法。
当我们使用WildFly webservices子系统时,Web服务正确发布,但在WS实现中,我们无法访问spring managed beans。
当我们在jboss-deployment-structure.xml中排除webservices子系统时,在web.xml中配置CXFServlet并在spring xml配置文件中配置jaxws:endpoint,日志显示服务创建正常,但不是基于真正的实施。错误的服务名称,名称空间和地址。
使用弹簧配置:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint id="testWs" implementor="ns.test.ws.impl.TestWsImpl"
address="/test">
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>
</beans>
记录内容:
18:31:11,783 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService线程池 - 58)从中加载XML bean定义 类路径资源[META-INF / cxf-beans.xml]
18:31:12,177 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService线程池 - 58)从中加载XML bean定义 类路径资源[META-INF / cxf / cxf.xml]
18:31:12,290 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService线程池 - 58)从中加载XML bean定义 类路径资源[META-INF / cxf / cxf-extension-jaxws.xml]
18:31:12,455 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService线程池 - 58)从中加载XML bean定义 类路径资源[META-INF / cxf / cxf-servlet.xml]
18:31:12,960 信息 [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (ServerService线程池 - 58)创建服务 来自类的{http://impl.ws.test.ns/} TestWsImplService ns.test.ws.impl.TestWsImpl
WS实施:
package ns.test.ws.impl;
import java.util.ArrayList;
import javax.jws.WebService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import ns.test.ws.api.TestWs;
import ns.test.ws.domain.ApplicationInfo;
import ns.test.ws.domain.ApplicationInfoRequest;
import ns.test.ws.domain.ApplicationInfoResultContainer;
import ns.test.ws.domain.CallContext;
import ns.test.ws.domain.ResultContext;
import ns.test.ws.domain.ResultMessage;
@WebService(name = "ApplicationInfoService", serviceName = "ApplicationInfoService", portName = "ApplicationInfoServicePort", endpointInterface = "ns.test.ws.api.TestWs", targetNamespace = "http://test.ns/")
@Transactional
public class TestWsImpl implements TestWs {
@SuppressWarnings("unused")
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(TestWsImpl.class);
@Autowired
private VersionInfo versionInfo;
public ApplicationInfoResultContainer test(CallContext callContext, ApplicationInfoRequest appInfoRequest) {
ApplicationInfo result = new ApplicationInfo();
result.setAppName(versionInfo.getAppName());
result.setAppVersion(versionInfo.getVersion());
ResultContext resultContext = new ResultContext();
resultContext.setCorrelationId("corrId");
resultContext.setHighestMessageSeverity("W");
resultContext.setMessageList(new ArrayList<ResultMessage>());
resultContext.getMessageList().add(new ResultMessage("code", "sev", "system", "message"));
return new ApplicationInfoResultContainer(result, resultContext);
}
}
我们错了什么?我们应该如何配置弹簧应用程序?
使用的依赖项:
WildFly 10.1
CXF 3.1.6(WildFly 10.1模块)
春天4.3.7