0
votes

We would like to migrate our Spring application from JBoss 7.1.1 to WildFly 10.1. We used CXF based and Spring managed web services but on WildFly 10.1 we couldn't configure these services.

We tried two methods.

  1. When we use WildFly webservices subsystem the web services are published correctly but in WS implementation we can't access spring managed beans.

  2. When we exclude webservices subsystem in the jboss-deployment-structure.xml, configure CXFServlet in web.xml and configure jaxws:endpoint in spring xml configuration file the log shows that service creation is ok, but not based on the real implementation. Wrong service name, namespace and address.

Used spring configuration:

<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>

Log content:

18:31:11,783 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 58) Loading XML bean definitions from class path resource [META-INF/cxf-beans.xml]
18:31:12,177 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 58) Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
18:31:12,290 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 58) Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-jaxws.xml]
18:31:12,455 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 58) Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
18:31:12,960 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (ServerService Thread Pool -- 58) Creating Service {http://impl.ws.test.ns/}TestWsImplService from class ns.test.ws.impl.TestWsImpl

WS implementation:

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);
   }
}

What do we wrong? How should we configure the spring application?

Used dependencies:

WildFly 10.1
CXF 3.1.6 (WildFly 10.1 module)
Spring 4.3.7

1

1 Answers

1
votes

I found the solution. See my sample code on the following repo.

https://github.com/SeniorRoland/spring-wildfly