Author: dkulp
Date: Wed Jan 10 09:21:11 2007
New Revision: 494900
URL: http://svn.apache.org/viewvc?view=rev&rev=494900
Log:
Temp fix for CXF-292
* Use the wsdl path specified in the cxf-servlet.xml file to load the wsdl
(code will probably change if servlet moved out of jaxws frontend)
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java?view=diff&rev=494900&r1=494899&r2=494900
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/servlet/CXFServlet.java
Wed Jan 10 09:21:11 2007
@@ -22,6 +22,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Hashtable;
import java.util.Map;
import java.util.logging.Logger;
@@ -34,6 +36,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.ws.Provider;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -46,6 +49,10 @@
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.jaxws.JAXWSMethodInvoker;
+import org.apache.cxf.jaxws.ProviderInvoker;
+import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
import org.apache.cxf.resource.URIResolver;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
@@ -185,6 +192,7 @@
buildEndpoint(implName, serviceName, wsdlName, portName, urlPat);
}
+ @SuppressWarnings("unchecked")
public void buildEndpoint(String implName, String serviceName, String
wsdlName, String portName,
String urlPat) throws ServletException {
@@ -193,7 +201,42 @@
Class cls = ClassLoaderUtils.loadClass(implName, getClass());
Object impl = cls.newInstance();
- EndpointImpl ep = new EndpointImpl(bus, impl, (String)null);
+ JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(cls);
+
+ JaxWsServiceFactoryBean serviceFactory = new
JaxWsServiceFactoryBean();
+ serviceFactory.setBus(bus);
+ if (implInfo.isWebServiceProvider()) {
+ serviceFactory.setInvoker(new
ProviderInvoker((Provider<?>)impl));
+ } else {
+ serviceFactory.setInvoker(new JAXWSMethodInvoker(impl));
+ }
+ serviceFactory.setServiceClass(impl.getClass());
+
+ if (!"".equals(wsdlName)) {
+ URL url = null;
+ try {
+ url = new URL(wsdlName);
+ } catch (MalformedURLException e) {
+ //ignore
+ }
+ if (url == null) {
+ try {
+ url =
getServletConfig().getServletContext().getResource("/" + wsdlName);
+ } catch (MalformedURLException e) {
+ //ignore
+ }
+ }
+ if (url == null) {
+ try {
+ url =
getServletConfig().getServletContext().getResource(wsdlName);
+ } catch (MalformedURLException e) {
+ //ignore
+ }
+ }
+ serviceFactory.setWsdlURL(url);
+ }
+
+ EndpointImpl ep = new EndpointImpl(bus, impl, serviceFactory);
LOG.info("publish the servcie to {context}/ " + (urlPat.charAt(0)
== '/' ? "" : "/") + urlPat);
// TODO we may need to get the url-pattern from servlet context