Author: ffang Date: Mon Jan 14 04:52:49 2013 New Revision: 1432803 URL: http://svn.apache.org/viewvc?rev=1432803&view=rev Log: Merged revisions 1432800 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes
................ r1432800 | ffang | 2013-01-14 12:44:04 +0800 (一, 14 1 2013) | 9 lines Merged revisions 1432798 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1432798 | ffang | 2013-01-14 12:32:40 +0800 (一, 14 1 2013) | 1 line [CXF-4676]Partial WSDL support in CXF ........ ................ Added: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/PartialWSDLProcessor.java - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/PartialWSDLProcessor.java cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SOAPBindingUtil.java - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SOAPBindingUtil.java cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/AddNumbersImplPartial1.java - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/AddNumbersImplPartial1.java cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/AddNumbersImplPartial2.java - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/AddNumbersImplPartial2.java cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerPartialWsdlTest.java - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ClientServerPartialWsdlTest.java cxf/branches/2.6.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerPartialWsdl.java - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/ServerPartialWsdl.java cxf/branches/2.6.x-fixes/systests/jaxws/src/test/resources/partialwsdl/ - copied from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/partialwsdl/ cxf/branches/2.6.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial1Service.wsdl - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial1Service.wsdl cxf/branches/2.6.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial1Service_schema1.xsd - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial1Service_schema1.xsd cxf/branches/2.6.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial2Service.wsdl - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial2Service.wsdl cxf/branches/2.6.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial2Service_schema1.xsd - copied unchanged from r1432800, cxf/branches/2.7.x-fixes/systests/jaxws/src/test/resources/partialwsdl/AddNumbersImplPartial2Service_schema1.xsd Modified: cxf/branches/2.6.x-fixes/ (props changed) cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.7.x-fixes:r1432800 Merged /cxf/trunk:r1432798 Propchange: cxf/branches/2.6.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=1432803&r1=1432802&r2=1432803&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original) +++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Mon Jan 14 04:52:49 2013 @@ -46,7 +46,9 @@ import java.util.concurrent.Executor; import java.util.logging.Level; import java.util.logging.Logger; +import javax.wsdl.Definition; import javax.wsdl.Operation; +import javax.wsdl.WSDLException; import javax.xml.bind.annotation.XmlAttachmentRef; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlList; @@ -105,6 +107,7 @@ import org.apache.cxf.service.model.Oper import org.apache.cxf.service.model.SchemaInfo; import org.apache.cxf.service.model.ServiceInfo; import org.apache.cxf.service.model.UnwrappedOperationInfo; +import org.apache.cxf.wsdl.WSDLManager; import org.apache.cxf.wsdl11.WSDLServiceBuilder; import org.apache.cxf.wsdl11.WSDLServiceFactory; import org.apache.ws.commons.schema.XmlSchema; @@ -525,7 +528,7 @@ public class ReflectionServiceFactoryBea } protected boolean isFromWsdl() { - return !populateFromClass && getWsdlURL() != null; + return !populateFromClass && getWsdlURL() != null && !isEmptywsdl(getWsdlURL()); } protected void initializeServiceModel() { @@ -2582,4 +2585,16 @@ public class ReflectionServiceFactoryBea public void setSchemaLocations(List<String> schemaLocations) { this.schemaLocations = schemaLocations; } + private boolean isEmptywsdl(String wsdlUrl) { + Definition definition; + try { + definition = getBus().getExtension(WSDLManager.class).getDefinition(wsdlUrl); + } catch (WSDLException e) { + return true; + } + if (definition.getPortTypes().isEmpty() && definition.getImports().isEmpty()) { + return true; + } + return false; + } } Modified: cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java?rev=1432803&r1=1432802&r2=1432803&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java (original) +++ cxf/branches/2.6.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceFactory.java Mon Jan 14 04:52:49 2013 @@ -22,15 +22,21 @@ package org.apache.cxf.wsdl11; import java.net.URL; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.logging.Logger; +import javax.wsdl.Binding; import javax.wsdl.Definition; +import javax.wsdl.PortType; import javax.wsdl.WSDLException; +import javax.wsdl.extensions.ExtensionRegistry; +import javax.wsdl.factory.WSDLFactory; import javax.xml.namespace.QName; import org.apache.cxf.Bus; import org.apache.cxf.common.i18n.Message; import org.apache.cxf.common.logging.LogUtils; +import org.apache.cxf.helpers.CastUtils; import org.apache.cxf.service.Service; import org.apache.cxf.service.ServiceImpl; import org.apache.cxf.service.factory.AbstractServiceFactoryBean; @@ -136,7 +142,34 @@ public class WSDLServiceFactory extends } else { javax.wsdl.Service wsdlService = definition.getService(serviceName); if (wsdlService == null) { - throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName)); + if ((!PartialWSDLProcessor.isServiceExisted(definition, serviceName)) + && (!PartialWSDLProcessor.isBindingExisted(definition, serviceName)) + && (PartialWSDLProcessor.isPortTypeExisted(definition, serviceName))) { + try { + Map<QName, PortType> portTypes = CastUtils.cast(definition.getPortTypes()); + String existPortName = null; + PortType portType = null; + for (QName existPortQName : portTypes.keySet()) { + existPortName = existPortQName.getLocalPart(); + if (serviceName.getLocalPart().contains(existPortName)) { + portType = portTypes.get(existPortQName); + break; + } + } + WSDLFactory factory = WSDLFactory.newInstance(); + ExtensionRegistry extReg = factory.newPopulatedExtensionRegistry(); + Binding binding = PartialWSDLProcessor.doAppendBinding(definition, + existPortName, portType, extReg); + definition.addBinding(binding); + wsdlService = PartialWSDLProcessor.doAppendService(definition, + existPortName, extReg, binding); + definition.addService(wsdlService); + } catch (Exception e) { + throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName)); + } + } else { + throw new ServiceConstructionException(new Message("NO_SUCH_SERVICE_EXC", LOG, serviceName)); + } } try { services = new WSDLServiceBuilder(getBus()).buildServices(definition,
