Author: rsearls
Date: 2014-05-29 15:21:45 -0400 (Thu, 29 May 2014)
New Revision: 18703
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
Log:
changes to support host UNDEFINED_HOSTNAME sceniaro
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-05-29
07:21:34 UTC (rev 18702)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-05-29
19:21:45 UTC (rev 18703)
@@ -25,6 +25,7 @@
import java.net.URI;
import java.net.URL;
+import org.apache.cxf.common.util.StringUtils;
import org.jboss.wsf.spi.management.ServerConfig;
@@ -182,12 +183,12 @@
}
- public static String rewriteSoapAddress(ServerConfig serverConfig, String address,
String contextRoot)
+ public static String rewriteSoapAddress(ServerConfig serverConfig, String address)
{
try
{
final String additionalCcontext = serverConfig.getWebServicePath();
- if (serverConfig.isModifySOAPAddress() && (additionalCcontext != null
&& additionalCcontext.length() > 0))
+ if (isSoapAddressRewrite(serverConfig))
{
final URL url = new URL(address);
final String path = url.getPath();
@@ -208,4 +209,8 @@
return address;
}
}
+
+ public static boolean isSoapAddressRewrite(ServerConfig sc){
+ return (sc.isModifySOAPAddress() &&
!StringUtils.isEmpty(sc.getWebServicePath()));
+ }
}
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-05-29
07:21:34 UTC (rev 18702)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-05-29
19:21:45 UTC (rev 18703)
@@ -25,7 +25,9 @@
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.frontend.WSDLGetUtils;
+import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
+import org.apache.cxf.message.Message;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.ServiceInfo;
@@ -35,17 +37,15 @@
import org.jboss.wsf.spi.metadata.config.CommonConfig;
import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
-
+import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
import javax.xml.namespace.QName;
import java.io.IOException;
-import java.net.URL;
import java.security.AccessController;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.jboss.wsf.stack.cxf.Loggers.ADDRESS_REWRITE_LOGGER;
/**
* An extension of @see org.apache.cxf.jaxws.EndpointImpl for dealing with
@@ -76,6 +76,10 @@
super.getServerFactory().setBlockPostConstruct(true);
super.doPublish(addr);
+ // A custom interceptor is required when the server config attributes for
rewriting
+ // the path in a WSDL URL (i.e., <soap:address location= ...) are set
+ setCustomInterceptor();
+
//allow for configuration so that the wsdlPublisher can be set be the
JBossWSCXFConfigurer
configureObject(this);
setupConfigHandlers();
@@ -84,6 +88,28 @@
}
/**
+ * A custom interceptor is required when the server config attributes for rewriting
+ * the path in a WSDL URL (i.e., <soap:address location= ...) are set
+ */
+ private void setCustomInterceptor(){
+ if (SoapAddressRewriteHelper.isSoapAddressRewrite(getServerConfig())) {
+ Collection<Endpoint> epList = super.getService().getEndpoints().values();
+ for (Endpoint ep : epList) {
+ List<Interceptor<? extends Message>> inList =
ep.getInInterceptors();
+ for (Interceptor in : inList) {
+ if (in instanceof org.apache.cxf.frontend.WSDLGetInterceptor) {
+ int index = inList.indexOf(in);
+ if (index > -1) {
+ inList.remove(index);
+ inList.add(index, WSDLSoapAddressRewriteInterceptor.INSTANCE);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
* Sets the JAXWS endpoint config for the current endpoint. This is called by
configurer when
* org.apache.cxf.jaxws.EndpointImpl#getServer(..) executes
'configureObject(this)'
*
@@ -139,8 +165,8 @@
if (wsdlLocation == null) {
JaxWsImplementorInfo info = new
JaxWsImplementorInfo(getImplementorClass());
wsdlLocation = info.getWsdlLocation();
- updateCodeFirstSoapAddress();
}
+ updateCodeFirstSoapAddress();
wsdlPublisher.publishWsdlFiles(service.getName(), wsdlLocation,
this.getBus(), service.getServiceInfos());
}
catch (IOException ioe)
@@ -186,12 +212,12 @@
}
/**
- * In the code-first scenario, reset the endpoint address so that it is
- * written to the generated wsdl file.
+ * For both code-first and wsdl-first scenarios, reset the endpoint address
+ * so that it is written to the generated wsdl file.
*/
private void updateCodeFirstSoapAddress() {
ServerConfig servConfig = getServerConfig();
- if (!SoapAddressRewriteHelper.isAutoRewriteOn(servConfig)) {
+ if (servConfig.isModifySOAPAddress()) {
//- code-first handling
List<ServiceInfo> sevInfos =
getServer().getEndpoint().getService().getServiceInfos();
for (ServiceInfo si: sevInfos){
@@ -200,6 +226,12 @@
String publishedEndpointUrl =
(String)ei.getProperty(WSDLGetUtils.PUBLISHED_ENDPOINT_URL);
if (publishedEndpointUrl != null){
ei.setAddress(publishedEndpointUrl);
+ } else {
+ //- wsdl-first handling
+ if (ei.getAddress().contains(ServerConfig.UNDEFINED_HOSTNAME)){
+ String epurl =
SoapAddressRewriteHelper.rewriteSoapAddress(servConfig, ei.getAddress());
+ ei.setAddress(epurl);
+ }
}
}
}
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2014-05-29
07:21:34 UTC (rev 18702)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2014-05-29
19:21:45 UTC (rev 18703)
@@ -303,7 +303,7 @@
//same comment as above regarding auto rewrite...
if (!SoapAddressRewriteHelper.isAutoRewriteOn(sc)) {
//- code-first handling
- String base = SoapAddressRewriteHelper.rewriteSoapAddress(sc,
ddep.getAddress(), dep.getService().getContextRoot());
+ String base = SoapAddressRewriteHelper.rewriteSoapAddress(sc,
ddep.getAddress());
ddep.setPublishedEndpointUrl(base); //force computed address for code first
endpoints
}
}
Modified:
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
===================================================================
---
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-05-29
07:21:34 UTC (rev 18702)
+++
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-05-29
19:21:45 UTC (rev 18703)
@@ -623,7 +623,6 @@
Definition definition = getWSDLDefinition(wsdlLocation);
String address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
assertEquals("http://" + serverHost + ":8080/" + addContext
+"/CodeFirstService", address);
-
if (isTestsuiteServerHostLocalhost()) {
definition =
getWSDLDefinition("http://127.0.0.1:8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl");
address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
@@ -665,7 +664,6 @@
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
"127.0.0.1");
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
"127.0.0.1");
}
-
for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
String wsdlLocation = entry.getKey();
String host = entry.getValue();