Hello, I'm trying to get a web client to work with a CXF web service and I'm having trouble with setting up Spring ( I think). I have a WS deployed and I generated the client code with WSDL2Java. I wrote a web page and a servlet to interact with the WS. When I deploy to Tomcat6 the CXFServlet says there is no service available. My index page is not showing up. The only thing I can think of is that it is not configured correctly. Any help would be greatly appreciated.
Beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!--<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:client id="CalculatorClient" serviceClass="com.lilly.Calculator" address=" http://dev0-royals.am.lilly.com:8080/JavaCalculator/CalculatorImpl"/> </beans> Web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/beans.xml</param-value> </context-param> <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> <servlet-name>ServiceClient</servlet-name> <servlet-class>com.lilly.client.ServiceClient</servlet-class> </servlet>--> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> <!--<servlet-mapping> <servlet-name>ServiceClient</servlet-name> <url-pattern>/ServiceClient</url-pattern> </servlet-mapping>--> <session-config> <session-timeout> 30 </session-timeout> </session-config> <!-- <service-ref> <service-ref-name>JavaCalculator/CalculatorImpl</service-ref-name> <service-interface>com.lilly.Calculator</service-interface> <wsdl-file> http://dev0-royals.am.lilly.com:8080/JavaCalculator/CalculatorImpl?wsdl </wsdl-file> </service-ref>--> <welcome-file-list> <welcome-file>index.jsp</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app> Servlet package com.lilly.client; import com.lilly.*; import java.io.*; import java.net.*; import javax.annotation.Resource; import java.net.URL; import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.servlet.*; import javax.servlet.http.*; import javax.xml.ws.WebServiceContext; import javax.xml.ws.WebServiceRef; /** * * @author eb96409 */ public class ServiceClient extends HttpServlet{ @WebServiceRef(wsdlLocation = " http://dev0-royals.am.lilly.com:8080/JavaCalculator/CalculatorImpl?wsdl") private static final QName SERVICE_NAME = new QName("http://lilly.com/", "Calculator"); @Resource protected WebServiceContext context; protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try{ int i = Integer.parseInt(request.getParameter("value1")); int j = Integer.parseInt(request.getParameter("value2")); URL wsdlURL = new URL(" http://dev0-royals.am.lilly.com/JavaCalculator/CalculatorImpl?wsdl"); Service service = Service.create(wsdlURL, SERVICE_NAME); Calculator client = service.getPort(Calculator.class); int result = client.multiply(i,j); out.println("<br/>"); out.println("Result:"); out.println("" + i + " x " + j + " = " + result); }finally { out.close(); } } }
