Author: asoldano
Date: 2015-04-15 17:46:07 -0400 (Wed, 15 Apr 2015)
New Revision: 19639
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Messages.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
Log:
[JBWS-3904] WSDLcontract retrieval enhancement and early availability check
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Messages.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Messages.java 2015-04-15
21:45:09 UTC (rev 19638)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/Messages.java 2015-04-15
21:46:07 UTC (rev 19639)
@@ -220,4 +220,7 @@
@Message(id = 24108, value = "Invalid request received:bindingOperation and
dispatched method are missing for service implementation invocation")
IllegalArgumentException missingBindingOpeartionAndDispatchedMethod();
+
+ @Message(id = 24109, value = "Could not get WSDL contract for endpoint %s at
%s")
+ WSFException couldNotFetchWSDLContract(String endpoint, String wsdlLocation);
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2015-04-15
21:45:09 UTC (rev 19638)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2015-04-15
21:46:07 UTC (rev 19639)
@@ -45,6 +45,7 @@
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.HttpEndpoint;
+import org.jboss.wsf.spi.deployment.ResourceResolver;
import org.jboss.wsf.spi.metadata.config.SOAPAddressRewriteMetadata;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
@@ -86,8 +87,9 @@
ddep.setInvoker(JBossWSInvoker.class.getName());
}
processWSDDContribution(ddep, (ArchiveDeployment)dep);
- processAddressRewrite(ddep, (ArchiveDeployment)dep, sarm,
soapAddressWsdlParsers);
-
+ URL wsdlLocation = getWsdlLocationURL(ddep,
((ArchiveDeployment)dep).getResourceResolver());
+ processAddressRewrite(ddep, wsdlLocation, sarm, soapAddressWsdlParsers);
+
METADATA_LOGGER.addingServiceEndpointMetadata(METADATA_LOGGER.isDebugEnabled() ?
ddep.toStringExtended() : ddep.toString());
dd.addEndpoint(ddep);
serviceNameAddressMap.put(ddep.getServiceName(), ddep.getAddress());
@@ -203,7 +205,6 @@
Class<?> seiClass = null;
String seiName;
- boolean missingServicePortAttr = false;
String name = (anWebService != null) ? anWebService.name() : "";
if (name.length() == 0)
@@ -211,7 +212,6 @@
String serviceName = (anWebService != null) ? anWebService.serviceName() :
anWebServiceProvider.serviceName();
if (serviceName.length() == 0) {
- missingServicePortAttr = true;
serviceName = JavaUtils.getJustClassName(sepClass) + "Service";
}
@@ -221,7 +221,6 @@
String portName = (anWebService != null) ? anWebService.portName() :
anWebServiceProvider.portName();
if (portName.length() == 0) {
- missingServicePortAttr = true;
portName = name + "Port";
}
@@ -273,36 +272,44 @@
}
}
result.setProperties(props);
- if (!missingServicePortAttr && annWsdlLocation.length() > 0) {
+ if (annWsdlLocation.length() > 0) {
result.setAnnotationWsdlLocation(annWsdlLocation);
}
return result;
}
- protected void processAddressRewrite(DDEndpoint ddep, ArchiveDeployment dep,
SOAPAddressRewriteMetadata sarm, Map<String, SOAPAddressWSDLParser>
soapAddressWsdlParsers)
- {
+ protected URL getWsdlLocationURL(DDEndpoint ddep, ResourceResolver resolver) {
String wsdlLocation = ddep.getWsdlLocation();
if (wsdlLocation == null) {
wsdlLocation = ddep.getAnnotationWsdlLocation();
}
if (wsdlLocation != null) {
- URL wsdlUrl = dep.getResourceResolver().resolveFailSafe(wsdlLocation);
- if (wsdlUrl != null) {
- SOAPAddressWSDLParser parser = getCurrentSOAPAddressWSDLParser(wsdlUrl,
soapAddressWsdlParsers);
- //do not try rewriting addresses for not-http binding
- String wsdlAddress = parser.filterSoapAddress(ddep.getServiceName(),
ddep.getPortName(), SOAPAddressWSDLParser.SOAP_HTTP_NS);
-
- String rewrittenWsdlAddress =
SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(wsdlAddress, ddep.getAddress(),
sarm);
- //If "auto rewrite", leave "publishedEndpointUrl" unset
so that CXF does not force host/port values for
- //wsdl imports and auto-rewrite them too; otherwise set the new address into
"publishedEndpointUrl",
- //which causes CXF to override any address in the published wsdl.
- if (!SoapAddressRewriteHelper.isAutoRewriteOn(sarm)) {
- ddep.setPublishedEndpointUrl(rewrittenWsdlAddress);
- }
+ URL wsdlURL = resolver.resolveFailSafe(wsdlLocation);
+ if (wsdlURL != null) {
+ return wsdlURL;
} else {
- METADATA_LOGGER.abortSoapAddressRewrite(wsdlLocation, null);
+ throw MESSAGES.couldNotFetchWSDLContract(ddep.getImplementor(),
wsdlLocation);
}
} else {
+ return null;
+ }
+ }
+
+ protected void processAddressRewrite(DDEndpoint ddep, URL wsdlUrl,
SOAPAddressRewriteMetadata sarm, Map<String, SOAPAddressWSDLParser>
soapAddressWsdlParsers)
+ {
+ if (wsdlUrl != null) {
+ SOAPAddressWSDLParser parser = getCurrentSOAPAddressWSDLParser(wsdlUrl,
soapAddressWsdlParsers);
+ //do not try rewriting addresses for not-http binding
+ String wsdlAddress = parser.filterSoapAddress(ddep.getServiceName(),
ddep.getPortName(), SOAPAddressWSDLParser.SOAP_HTTP_NS);
+
+ String rewrittenWsdlAddress =
SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(wsdlAddress, ddep.getAddress(),
sarm);
+ //If "auto rewrite", leave "publishedEndpointUrl" unset so
that CXF does not force host/port values for
+ //wsdl imports and auto-rewrite them too; otherwise set the new address into
"publishedEndpointUrl",
+ //which causes CXF to override any address in the published wsdl.
+ if (!SoapAddressRewriteHelper.isAutoRewriteOn(sarm)) {
+ ddep.setPublishedEndpointUrl(rewrittenWsdlAddress);
+ }
+ } else {
//same comment as above regarding auto rewrite...
if (!SoapAddressRewriteHelper.isAutoRewriteOn(sarm)) {
//force computed address for code first endpoints