Help Struts 2 + Spring + WebService(CXF)

0 respostas
fabioebner

Amigos tenho uma aplicacao rodando Struts 2 + Spring, porem agora gostaria de disponibilizar alguns servicos via WebService, estou tentando o CXF porem estou com alguns problemas, segui o exemplo do site: http://cxf.apache.org/docs/writing-a-service-with-spring.html

criei a classe:
package br.com.dnasolution.site.ws;

import javax.jws.WebService;

@WebService
public interface HelloWorld {
    String sayHi(String text);

}
depois
package br.com.dnasolution.site.ws;

import javax.jws.WebService;

@WebService(endpointInterface = "br.com.dnasolution.site.ws.HelloWorld")
public class HelloWorldImpl implements HelloWorld {

    public String sayHi(String text) {
        System.out.println("sayHi called");
        return "Hello " + text;
    }
}
coloquei no meu applicationContext.xml
<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:aop="http://www.springframework.org/schema/aop"
	   xmlns:tx="http://www.springframework.org/schema/tx"
	   xmlns:jaxws="http://cxf.apache.org/jaxws"
	   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-2.5.xsd
		http://www.springframework.org/schema/aop
		http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
		http://www.springframework.org/schema/tx
		http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
		http://cxf.apache.org/jaxws 
		http://cxf.apache.org/schemas/jaxws.xsd
		">

	<context:annotation-config/>
	<context:component-scan base-package="br"/>
	<aop:aspectj-autoproxy/>


<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

	<jaxws:endpoint 
	  id="helloWorld" 
	  implementor="br.com.dnasolution.site.ws.HelloWorldImpl" 
	  address="/HelloWorld" />
....
e no meu Web.Xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xmlns="http://java.sun.com/xml/ns/javaee"
		 xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
		 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
		 id="WebApp_ID"
		 version="2.5">
	<display-name>DnaSolution</display-name>

	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<listener>
		<listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
	</listener>

	<servlet>
		<servlet-name>CXFServlet</servlet-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>

	<!--
		 <filter>
		 <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
		 <filter-class>
		 org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
		 </filter-class>
		 </filter>

		 <filter-mapping>
		 <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
		 <url-pattern>/*</url-pattern>
		 </filter-mapping>
	-->


	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>
</web-app>

porem nao consigo fazer funcionar, como eu deixei os dois mapeando o /* quando tento acessar o root ja comeca dando erro, perfeito mudei no web.xml o url pattern do meu CXF, para /ws/*, assim eu consigo rodar o Struts porem nao consegui funcionar o WS(tento colocar localhost:8080/app/ws/HelloWord?wsdl e nada)

alguem pode me ajudar a integrar os dois??

obrigado

Criado 7 de julho de 2010
Respostas 0
Participantes 1