You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/08/15 21:32:26 UTC
svn commit: r686341 - in /cxf/branches/2.0.x-fixes: ./
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Author: dkulp
Date: Fri Aug 15 12:32:25 2008
New Revision: 686341
URL: http://svn.apache.org/viewvc?rev=686341&view=rev
Log:
Merged revisions 686299 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r686299 | dkulp | 2008-08-15 14:09:31 -0400 (Fri, 15 Aug 2008) | 2 lines
Slight speed up when creating a service. Don't process the wsdl into a servicemodel, just grab the port information out of it for JAXWS usage.
........
Modified:
cxf/branches/2.0.x-fixes/ (props changed)
cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 15 12:32:25 2008
@@ -1 +1 @@
-/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237,686283
+/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237,686283,686299
Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Aug 15 12:32:25 2008
@@ -1 +1 @@
-/cxf/trunk:1-684881,684883-684884,684886-684888,684890-684892,684894-684923,685205,685253,686237,686283
+/cxf/trunk:1-684881,684883-684884,684886-684888,684890-684892,684894-684923,685205,685253,686237,686283,686299
Modified: cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=686341&r1=686340&r2=686341&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original)
+++ cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Fri Aug 15 12:32:25 2008
@@ -34,6 +34,13 @@
import java.util.logging.Logger;
import javax.jws.WebService;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.ws.Dispatch;
@@ -59,6 +66,7 @@
import org.apache.cxf.endpoint.EndpointException;
import org.apache.cxf.endpoint.ServiceContractResolverRegistry;
import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
import org.apache.cxf.jaxws.handler.HandlerResolverImpl;
@@ -76,12 +84,16 @@
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.service.model.ServiceModelUtil;
+import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
+import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
import org.apache.cxf.tools.util.URIParserUtil;
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.workqueue.OneShotAsyncExecutor;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl.http.AddressType;
import org.apache.cxf.wsdl11.WSDLServiceFactory;
public class ServiceImpl extends ServiceDelegate {
@@ -93,12 +105,14 @@
private String wsdlURL;
private HandlerResolver handlerResolver;
- private final Collection<QName> ports = new HashSet<QName>();
- private Map<QName, PortInfoImpl> portInfos = new HashMap<QName, PortInfoImpl>();
private Executor executor;
private QName serviceName;
private Class<?> clazz;
+ private final Collection<QName> ports = new HashSet<QName>();
+ private Map<QName, PortInfoImpl> portInfos = new HashMap<QName, PortInfoImpl>();
+
+
public ServiceImpl(Bus b, URL url, QName name, Class<?> cls) {
bus = b;
this.serviceName = name;
@@ -133,14 +147,65 @@
}
}
- private void initializePorts() {
- WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
- Service service = sf.create();
- for (ServiceInfo si : service.getServiceInfos()) {
- for (EndpointInfo ei : si.getEndpoints()) {
- this.ports.add(ei.getName());
- String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
- addPort(ei.getName(), bindingID, ei.getAddress());
+ private void initializePorts() {
+ try {
+ Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
+ javax.wsdl.Service serv = def.getService(serviceName);
+ if (serv == null) {
+ throw new WebServiceException("Could not find service named " + serviceName
+ + " in wsdl " + wsdlURL);
+ }
+
+ Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
+ for (Port port : wsdlports.values()) {
+ QName name = new QName(serviceName.getNamespaceURI(), port.getName());
+
+ String tpId = null;
+ String address = null;
+ List<? extends ExtensibilityElement> extensions
+ = CastUtils.cast(port.getBinding().getExtensibilityElements());
+ if (!extensions.isEmpty()) {
+ ExtensibilityElement e = extensions.get(0);
+ if (e instanceof SoapBinding) {
+ tpId = ((SoapBinding)e).getTransportURI();
+ } else if (e instanceof SOAP12Binding) {
+ tpId = ((SOAP12Binding)e).getTransportURI();
+ } else if (e instanceof SOAPBinding) {
+ tpId = ((SOAPBinding)e).getTransportURI();
+ }
+ }
+ extensions = CastUtils.cast(port.getExtensibilityElements());
+ if (!extensions.isEmpty()) {
+ ExtensibilityElement e = extensions.get(0);
+ if (tpId == null) {
+ tpId = e.getElementType().getNamespaceURI();
+ }
+ if (e instanceof SoapAddress) {
+ address = ((SoapAddress)e).getLocationURI();
+ } else if (e instanceof AddressType) {
+ address = ((AddressType)e).getLocation();
+ } else if (e instanceof SOAP12Address) {
+ address = ((SOAP12Address)e).getLocationURI();
+ } else if (e instanceof SOAPAddress) {
+ address = ((SOAPAddress)e).getLocationURI();
+ }
+ }
+ this.ports.add(name);
+ String bindingID = BindingID.getJaxwsBindingID(tpId);
+ addPort(name, bindingID, address);
+ }
+ } catch (WebServiceException e) {
+ throw e;
+ } catch (Throwable e) {
+ e.printStackTrace();
+ WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
+ Service service = sf.create();
+ for (ServiceInfo si : service.getServiceInfos()) {
+ for (EndpointInfo ei : si.getEndpoints()) {
+ this.ports.add(ei.getName());
+ String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
+ addPort(ei.getName(), bindingID, ei.getAddress());
+ }
}
}
}