[jboss-svn-commits] JBL Code SVN: r25332 - in labs/jbossesb/branches/JBESB_4_4_GA_FP/product: rosetta/src/org/jboss/soa/esb/listeners/config/mappers110 and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Feb 18 23:47:05 EST 2009


Author: beve
Date: 2009-02-18 23:47:05 -0500 (Wed, 18 Feb 2009)
New Revision: 25332

Added:
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/JBossWSWebserviceContractPublisher.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java
Removed:
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlTransformer.java
Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/XMLBeansModel.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/XMLBeansModel.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml
   labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2405 "Create a contract publisher to handle remote WS endpoints"


Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/XMLBeansModel.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/XMLBeansModel.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/XMLBeansModel.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -388,8 +388,11 @@
                     publisher = (ActionContractPublisher) publisherClass.newInstance();
                     final org.jboss.soa.esb.listeners.config.Action actionInfo = new org.jboss.soa.esb.listeners.config.Action(
                         action.getName(), action.getClass1(), action.getProcess(), toProperties(action.getPropertyList())) ;
-                    publisher.setActionConfig(actionInfo);
-                    return publisher;
+
+                    if(actionInfo.getProperties().getProperty("publishContract", "true").equals("true")) {
+                        publisher.setActionConfig(actionInfo);
+                        return publisher;
+                    }
                 } catch (ClassCastException e) {
                     throw new RuntimeException("Action Contract Publisher class '" + publisherClass.getName() + "' must implement " + ActionContractPublisher.class.getName());
                 } catch (Exception e) {

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/XMLBeansModel.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/XMLBeansModel.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers110/XMLBeansModel.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -388,8 +388,11 @@
                     publisher = (ActionContractPublisher) publisherClass.newInstance();
                     final org.jboss.soa.esb.listeners.config.Action actionInfo = new org.jboss.soa.esb.listeners.config.Action(
                         action.getName(), action.getClass1(), action.getProcess(), toProperties(action.getPropertyList())) ;
-                    publisher.setActionConfig(actionInfo);
-                    return publisher;
+
+                    if(actionInfo.getProperties().getProperty("publishContract", "true").equals("true")) {
+                        publisher.setActionConfig(actionInfo);
+                        return publisher;
+                    }
                 } catch (ClassCastException e) {
                     throw new RuntimeException("Action Contract Publisher class '" + publisherClass.getName() + "' must implement " + ActionContractPublisher.class.getName());
                 } catch (Exception e) {

Copied: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java (from rev 25124, labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import org.jboss.internal.soa.esb.publish.ActionContractPublisher;
+import org.jboss.internal.soa.esb.publish.ContractInfo;
+import org.jboss.internal.soa.esb.publish.ServletContractPublisher;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.soa.esb.listeners.config.Action;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.http.HttpClientFactory;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.xml.sax.SAXException;
+import org.milyn.container.ExecutionContext;
+import org.milyn.Smooks;
+import org.apache.log4j.Logger;
+
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.StringReader;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.Properties;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * Abstract WSDL contract publisher.
+ * 
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class AbstractWsdlContractPublisher implements ActionContractPublisher, ServletContractPublisher {
+
+    private static Logger logger = Logger.getLogger(AbstractWsdlContractPublisher.class);
+
+    public static final String REWRITE_ENDPOINT_URL = "rewrite-endpoint-url";
+
+    private boolean rewriteEndpointUrl = true;
+    private Smooks transformer;
+
+    /**
+     * Set the {@link SOAPProcessor} action configuration.
+     * @param actionConfig action config.
+     * @throws ConfigurationException Bad config.
+     */
+    public void setActionConfig(Action actionConfig) throws ConfigurationException {
+        final Properties properties = actionConfig.getProperties();
+
+        final String rewriteEndpointUrlVal = properties.getProperty(AbstractWsdlContractPublisher.REWRITE_ENDPOINT_URL);
+        if (rewriteEndpointUrlVal != null) {
+            rewriteEndpointUrl = !rewriteEndpointUrlVal.equals("false");
+        }
+
+        initializeEndpointRewriteTransformer();
+    }
+
+    /**
+     * Get the WSDL Address.
+     * @return The WSDL address.
+     */
+    public abstract String getWsdlAddress();
+
+    /**
+     * Get the {@link org.jboss.soa.esb.http.HttpClientFactory} properties.
+     * <p/>
+     * We use HttpClient (configurable via the {@link org.jboss.soa.esb.http.HttpClientFactory})
+     * to load the WSDL.  This way, we can support different auth mechanisms etc.
+     *
+     * @return The {@link org.jboss.soa.esb.http.HttpClientFactory} properties.
+     */
+    public abstract Properties getHttpClientProperties();
+
+    /**
+     * Get the contract configuration.
+     * <p/>
+     * This method impl basically returns the Endpoint WSDL, modified for
+     * the supplied EPR and its channel.
+     *
+     * @param epr Endpoint EPR.
+     * @return WSDL Contract.
+     */
+    public ContractInfo getContractInfo(EPR epr) {
+        HttpServletRequest httpServletRequestProxy;
+
+        httpServletRequestProxy = (HttpServletRequest) Proxy.newProxyInstance(HttpServletRequest.class.getClassLoader(),
+                                          new Class[] { HttpServletRequest.class },
+                                          new HttpServletRequestHandler());
+
+        return getContractInfo(epr, httpServletRequestProxy);
+    }
+
+    public ContractInfo getContractInfo(EPR epr, HttpServletRequest servletRequest) {
+        String wsdlAddress = getWsdlAddress();
+
+        if(wsdlAddress != null) {
+            String targetServiceCat = servletRequest.getParameter("serviceCat");
+            String targetServiceName = servletRequest.getParameter("serviceName");
+            String targetProtocol = servletRequest.getParameter("protocol");
+
+            try {
+                // Generate the WSDL...
+                String wsdl = getWsdl(wsdlAddress);
+
+                wsdl = updateWsdl(wsdl, epr, targetServiceCat, targetServiceName, targetProtocol);
+
+                return new ContractInfo("text/xml", wsdl);
+            } catch (Exception e) {
+                logger.error("Failed to load WSDL contract information from WS Endpoint '" + wsdlAddress + "'.", e);
+                return new ContractInfo("text/plain", "Unavailable: " + e.getMessage());
+            }
+        } else {
+            logger.warn("Requested contract info for unknown webservice endpoint'.");
+            return null;
+        }
+    }
+
+    /**
+     * Get the WSDL.
+     * @param wsdlAddress The WSDL address.
+     * @return The WSDL.
+     * @throws IOException Error reading wsdl.
+     */
+    private String getWsdl(String wsdlAddress) throws IOException {
+        RemoteWsdlLoader loader;
+
+        try {
+            Properties httpClientProperties = getHttpClientProperties();
+
+            httpClientProperties = (Properties) httpClientProperties.clone();            
+            if(!httpClientProperties.containsKey(HttpClientFactory.TARGET_HOST_URL)) {
+                httpClientProperties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlAddress);
+            }
+
+            loader = new RemoteWsdlLoader(httpClientProperties);
+        } catch (ConfigurationException e) {
+            throw (IOException)(new IOException("Failed to create RemoteWsdlLoader instance.").initCause(e));
+        }
+
+        InputStream wsdlStream = loader.load(wsdlAddress);
+        try {
+            return StreamUtils.readStreamString(wsdlStream, "UTF-8");
+        } finally {
+            wsdlStream.close();
+        }
+    }
+
+    /**
+     * Update the supplied wsdl to take account of the ESB endpoint proxying of the JBossWS
+     * invocation, as well as the fact that the transport may be different.
+     *
+     * @param wsdl WSDL input.
+     * @param epr The SOAP endpoint from the ESB perspective.
+     * @param targetServiceCat
+     * @param targetServiceName
+     * @param targetProtocol @return The updated WSDL.
+     */
+    protected String updateWsdl(String wsdl, EPR epr, String targetServiceCat, String targetServiceName, String targetProtocol) throws SAXException, IOException, ConfigurationException {
+        wsdl = rewriteEndpointAddresses(wsdl, epr, targetServiceCat, targetServiceName, targetProtocol);
+
+        return wsdl.trim();
+    }
+
+    /**
+     * Initialize the endpoint rewriting transformer.
+     * @throws ConfigurationException Failed to initialize transformer.
+     */
+    protected void initializeEndpointRewriteTransformer() throws ConfigurationException {
+        try {
+            transformer = new Smooks("/org/jboss/soa/esb/actions/soap/wsdltrans.xml");
+        } catch (IOException e) {
+            throw new ConfigurationException("Failed to read the Smooks Transformation config for WSDL.", e);
+        } catch (SAXException e) {
+            throw new ConfigurationException("Failed to read the Smooks Transformation config for WSDL.", e);
+        }
+    }
+
+    /**
+     * Perform the endpoint rewrite.
+     * @param wsdl The WSDL to be transformed.
+     * @param epr The target endpoint EPR on the ESB.
+     * @param targetServiceCat The Service Category.
+     * @param targetServiceName The Service Name.
+     * @param targetProtocol The target protocol.
+     * @return The rewritten WSDL.
+     */
+    private String rewriteEndpointAddresses(String wsdl, EPR epr, String targetServiceCat, String targetServiceName, String targetProtocol) {
+        if(!rewriteEndpointUrl && targetProtocol.startsWith("http")) {
+            // return the wsdl unchanged...
+            return wsdl;
+        }
+
+        URI endpointURI = URI.create(epr.getAddr().getAddress());
+        StringWriter writer = new StringWriter();
+        ExecutionContext execContext = transformer.createExecutionContext();
+
+        execContext.setAttribute(WsdlEndpointTransformer.ENDPOINT_URI, endpointURI);
+        execContext.setAttribute(WsdlEndpointTransformer.TARGET_CAT, targetServiceCat);
+        execContext.setAttribute(WsdlEndpointTransformer.TARGET_NAME, targetServiceName);
+        execContext.setAttribute(WsdlEndpointTransformer.TARGET_PROTOCOL, targetProtocol);
+        transformer.filter(new StreamSource(new StringReader(wsdl)), new StreamResult(writer), execContext);
+
+        return writer.toString().trim();
+    }
+
+    private class HttpServletRequestHandler implements InvocationHandler {
+        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            if(method.getName().equals("getRequestURL")) {
+                return new StringBuffer("http://www.jboss.org");
+            }
+
+            return null;
+        }
+    }
+}

Copied: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/JBossWSWebserviceContractPublisher.java (from rev 25124, labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/JBossWSWebserviceContractPublisher.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/JBossWSWebserviceContractPublisher.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/JBossWSWebserviceContractPublisher.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.listeners.config.Action;
+import org.jboss.wsf.spi.deployment.Endpoint;
+
+import java.util.Properties;
+
+/**
+ * Contract publisher for a JBossWS Webservice endpoint.
+ * 
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JBossWSWebserviceContractPublisher extends AbstractWsdlContractPublisher {
+
+    private static Logger logger = Logger.getLogger(JBossWSWebserviceContractPublisher.class);
+    private String endpointName;
+
+    /**
+     * Set the {@link SOAPProcessor} action configuration.
+     * @param actionConfig action config.
+     * @throws ConfigurationException Bad config.
+     */
+    public void setActionConfig(Action actionConfig) throws ConfigurationException {
+        // Initialise the abstract base class first...
+        super.setActionConfig(actionConfig);
+
+        endpointName = actionConfig.getProperties().getProperty(SOAPProcessor.JBOSSWS_ENDPOINT);
+        if(endpointName == null) {
+            throw new ConfigurationException("Property '" + SOAPProcessor.JBOSSWS_ENDPOINT + "' not specified.");
+        }
+    }
+
+    public String getWsdlAddress() {
+        Endpoint endpoint = SOAPProcessor.getServiceEndpoint(endpointName);
+
+        if(endpoint != null) {
+            return endpoint.getAddress() + "?wsdl";
+        } else {
+            logger.warn("Requested contract info for unknown webservice endpoint '" + endpointName + "'.");
+            return null;
+        }
+    }
+
+    public Properties getHttpClientProperties() {
+        return new Properties();
+    }
+}

Copied: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java (from rev 25124, labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/RemoteWsdlLoader.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.http.HttpClientFactory;
+import org.jboss.soa.esb.ConfigurationException;
+
+/**
+ * {@link HttpClientFactory} based WSLD loader.
+ * <p/>
+ * We use this in order to support different authentication modes that
+ * may be required for WSDL lookup.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class RemoteWsdlLoader {
+
+    private static Logger logger = Logger.getLogger(RemoteWsdlLoader.class);
+    private HttpClient httpClient;
+
+    public RemoteWsdlLoader(Properties httpClientProps) throws ConfigurationException {
+        this.httpClient = HttpClientFactory.createHttpClient(httpClientProps);
+    }
+
+    public InputStream load(String url) throws IOException {
+        GetMethod httpGetMethod;
+
+        if(url.startsWith("file")) {
+            return new URL(url).openStream();
+        }
+
+        // Authentication is not being overridden on the method.  It needs
+        // to be present on the supplied HttpClient instance!
+        httpGetMethod = new GetMethod(url);
+        httpGetMethod.setDoAuthentication(true);
+
+        try {
+            int result = httpClient.executeMethod(httpGetMethod);
+
+            if(result != HttpStatus.SC_OK) {
+                if(result < 200 || result > 299) {
+                    throw new HttpException("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
+                } else {
+                    logger.warn("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
+                }
+            }
+
+            return new ByteArrayInputStream(httpGetMethod.getResponseBody());
+        } finally {
+            httpGetMethod.releaseConnection();
+        }
+    }
+}
\ No newline at end of file

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -28,7 +28,6 @@
 import java.util.Properties;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URL;
 
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
@@ -42,6 +41,7 @@
 import org.apache.log4j.Logger;
 import org.jboss.internal.soa.esb.soap.OGNLUtils;
 import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.internal.soa.esb.publish.Publish;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
@@ -266,9 +266,11 @@
  *
  * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
  */
+ at Publish(WsdlContractPublisher.class)
 public class SOAPClient extends AbstractActionPipelineProcessor {
 
     private Logger logger = Logger.getLogger(SOAPClient.class);
+
     private String wsdl;
     private String soapAction;
     private String soapNs;

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPProcessor.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -106,11 +106,10 @@
  *
  * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
  */
- at Publish(WebserviceContractPublisher.class)
+ at Publish(JBossWSWebserviceContractPublisher.class)
 public class SOAPProcessor extends AbstractActionPipelineProcessor {
 
     public static final String JBOSSWS_ENDPOINT = "jbossws-endpoint";
-    public static final String REWRITE_ENDPOINT_URL = "rewrite-endpoint-url";
 
     private static ThreadLocal<Message> messageTL = new ThreadLocal<Message>();
     private String jbossws_endpoint;

Deleted: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -1,193 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.actions.soap;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.publish.ActionContractPublisher;
-import org.jboss.internal.soa.esb.publish.ContractInfo;
-import org.jboss.internal.soa.esb.publish.ServletContractPublisher;
-import org.jboss.internal.soa.esb.util.StreamUtils;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.listeners.config.Action;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.milyn.Smooks;
-import org.milyn.container.ExecutionContext;
-import org.xml.sax.SAXException;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URI;
-import java.net.URL;
-import java.util.Properties;
-
-/**
- * Contract publisher for a Webservice endpoint.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class WebserviceContractPublisher implements ActionContractPublisher, ServletContractPublisher {
-
-    private static Logger logger = Logger.getLogger(WebserviceContractPublisher.class);    
-    private String endpointName;
-    private boolean rewriteEndpointUrl = true;
-    private Smooks transformer;
-
-    /**
-     * Set the {@link SOAPProcessor} action configuration.
-     * @param actionConfig action config.
-     * @throws ConfigurationException Bad config.
-     */
-    public void setActionConfig(Action actionConfig) throws ConfigurationException {
-        final Properties properties = actionConfig.getProperties();
-
-        endpointName = properties.getProperty(SOAPProcessor.JBOSSWS_ENDPOINT);
-        final String rewriteEndpointUrlVal = properties.getProperty(SOAPProcessor.REWRITE_ENDPOINT_URL);
-        if (rewriteEndpointUrlVal != null) {
-            rewriteEndpointUrl = !rewriteEndpointUrlVal.equals("false");
-        }
-
-        if(endpointName == null) {
-            throw new ConfigurationException("Property '" + SOAPProcessor.JBOSSWS_ENDPOINT + "' not specified.");
-        }
-
-        initializeTransform();
-    }
-
-    /**
-     * Get the contract configuration.
-     * <p/>
-     * This method impl basically returns the Endpoint WSDL, modified for
-     * the supplied EPR and its channel.
-     *
-     * @param epr Endpoint EPR.
-     * @return WSDL Contract.
-     */
-    public ContractInfo getContractInfo(EPR epr) {
-        HttpServletRequest httpServletRequestProxy;
-
-        httpServletRequestProxy = (HttpServletRequest) Proxy.newProxyInstance(HttpServletRequest.class.getClassLoader(),
-                                          new Class[] { HttpServletRequest.class },
-                                          new HttpServletRequestHandler());
-
-        return getContractInfo(epr, httpServletRequestProxy);
-    }
-
-    public ContractInfo getContractInfo(EPR epr, HttpServletRequest servletRequest) {
-        Endpoint endpoint = SOAPProcessor.getServiceEndpoint(endpointName);
-
-        if(endpoint != null) {
-            String targetServiceCat = servletRequest.getParameter("serviceCat");
-            String targetServiceName = servletRequest.getParameter("serviceName");
-            String targetProtocol = servletRequest.getParameter("protocol");
-
-            try {
-                // Generate the WSDL...
-                String wsdl = getEndpointWsdl(endpoint);
-
-                wsdl = updateWsdl(wsdl, epr, targetServiceCat, targetServiceName, targetProtocol);
-
-                return new ContractInfo("text/xml", wsdl);
-            } catch (Exception e) {
-                logger.error("Failed to load contract information from JBossWS Endpoint '" + endpointName + "'.", e);
-                return new ContractInfo("text/plain", "Unavailable: " + e.getMessage());
-            }
-        } else {
-            logger.warn("Requested contract info for unknown webservice endpoint '" + endpointName + "'.");
-            return null;
-        }
-    }
-
-    /**
-     * Get the endpoints WSSDL from the JBossWS container.
-     * </p>
-     * See http://jira.jboss.com/jira/browse/JBWS-1909
-     *
-     * @param endpoint The endpoint.
-     * @return The WSDL.
-     * @throws IOException Error reading wsdl.
-     */
-    private String getEndpointWsdl(Endpoint endpoint) throws IOException {
-        URL endpointWsdlAddress = new URL(endpoint.getAddress() + "?wsdl");
-        InputStream wsdlStream = endpointWsdlAddress.openStream();
-
-        try {
-            return StreamUtils.readStreamString(wsdlStream, "UTF-8");
-        } finally {
-            wsdlStream.close();
-        }
-    }
-
-    /**
-     * Update the supplied wsdl to take account of the ESB endpoint proxying of the JBossWS
-     * invocation, as well as the fact that the transport may be different.
-     *
-     * @param wsdl WSDL input.
-     * @param epr The SOAP endpoint from the ESB perspective.
-     * @param targetServiceCat
-     * @param targetServiceName
-     * @param targetProtocol @return The updated WSDL.
-     */
-    protected String updateWsdl(String wsdl, EPR epr, String targetServiceCat, String targetServiceName, String targetProtocol) throws SAXException, IOException, ConfigurationException {
-        if(!rewriteEndpointUrl && targetProtocol.startsWith("http")) {
-            // return the wsdl unchanged...
-            return wsdl;
-        }
-
-        URI endpointURI = URI.create(epr.getAddr().getAddress());
-        StringWriter writer = new StringWriter();
-        ExecutionContext execContext = transformer.createExecutionContext();
-
-        execContext.setAttribute(WsdlTransformer.ENDPOINT_URI, endpointURI);
-        execContext.setAttribute(WsdlTransformer.TARGET_CAT, targetServiceCat);
-        execContext.setAttribute(WsdlTransformer.TARGET_NAME, targetServiceName);
-        execContext.setAttribute(WsdlTransformer.TARGET_PROTOCOL, targetProtocol);
-        transformer.filter(new StreamSource(new StringReader(wsdl)), new StreamResult(writer), execContext);
-
-        return writer.toString().trim();
-    }
-
-    protected void initializeTransform() throws ConfigurationException {
-        try {
-            transformer = new Smooks("/org/jboss/soa/esb/actions/soap/wsdltrans.xml");
-        } catch (IOException e) {
-            throw new ConfigurationException("Failed to read the Smooks Transformation config for WSDL.", e);
-        } catch (SAXException e) {
-            throw new ConfigurationException("Failed to read the Smooks Transformation config for WSDL.", e);
-        }
-    }
-
-    private class HttpServletRequestHandler implements InvocationHandler {
-        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-            if(method.getName().equals("getRequestURL")) {
-                return new StringBuffer("http://www.jboss.org");
-            }
-
-            return null;
-        }
-    }
-}

Copied: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java (from rev 25124, labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import org.jboss.soa.esb.listeners.config.Action;
+import org.jboss.soa.esb.ConfigurationException;
+
+import java.util.Properties;
+
+/**
+ * WSDL contract publisher.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WsdlContractPublisher extends AbstractWsdlContractPublisher {
+    
+    private Properties properties;
+
+    public void setActionConfig(Action actionConfig) throws ConfigurationException {
+        super.setActionConfig(actionConfig);
+
+        properties = actionConfig.getProperties();
+    }
+
+    public String getWsdlAddress() {
+        return properties.getProperty("wsdl");
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+
+    public Properties getHttpClientProperties() {
+        return properties;
+    }
+}

Copied: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java (from rev 25124, labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import org.milyn.delivery.dom.DOMElementVisitor;
+import org.milyn.container.ExecutionContext;
+import org.milyn.SmooksException;
+import org.milyn.xml.DomUtils;
+import org.milyn.cdr.SmooksResourceConfiguration;
+import org.milyn.cdr.SmooksConfigurationException;
+import org.w3c.dom.Element;
+import org.apache.log4j.Logger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * Smooks transformer for transforming the WSDL for ESB endpoints.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WsdlEndpointTransformer implements DOMElementVisitor {
+
+    private static Logger logger = Logger.getLogger(WsdlEndpointTransformer.class);
+
+    public static final String ENDPOINT_URI = "endpointURI";
+    public static final String TARGET_CAT = "targetServiceCat";
+    public static final String TARGET_NAME = "targetServiceName";
+    public static final String TARGET_PROTOCOL = "targetProtocol";
+
+    public void setConfiguration(SmooksResourceConfiguration smooksResourceConfiguration) throws SmooksConfigurationException {
+    }
+
+    public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
+    }
+
+    public void visitAfter(Element element, ExecutionContext executionContext) throws SmooksException {
+        String elementName = DomUtils.getName(element);
+
+        if(elementName.equals("import")) {
+            transformImport(element, executionContext);
+        } else if(elementName.equals("binding")) {
+            transformBinding(element, executionContext);
+        } else if(elementName.equals("address")) {
+            transformAddress(element, executionContext);
+        }
+    }
+
+    private void transformImport(Element element, ExecutionContext executionContext) {
+        String location = DomUtils.getAttributeValue(element, "location");
+
+        if(location != null) {
+            try {
+                URI locationURI = new URI(location);
+                String targetServiceCat = (String) executionContext.getAttribute(WsdlEndpointTransformer.TARGET_CAT);
+                String targetServiceName = (String) executionContext.getAttribute(WsdlEndpointTransformer.TARGET_NAME);
+                String targetProtocol = (String) executionContext.getAttribute(WsdlEndpointTransformer.TARGET_PROTOCOL);
+                String addParams = "serviceCat=" + targetServiceCat + "&serviceName=" + targetServiceName + "&protocol=" + targetProtocol;
+
+                if(locationURI.getQuery() != null) {
+                    element.setAttribute("location", (locationURI.toString() + "&" + addParams).replace("&", "&amp;"));
+                } else {
+                    element.setAttribute("location", (locationURI.toString() + "?" + addParams).replace("&", "&amp;"));
+                }
+            } catch (URISyntaxException e) {
+                logger.info("Not processing WSDL import '" + location + "'.  Invalid URI.");
+            }
+        }
+    }
+
+    private void transformBinding(Element element, ExecutionContext executionContext) {
+        URI endpointURI = (URI) executionContext.getAttribute(ENDPOINT_URI);
+        if(endpointURI != null) {
+            element.setAttribute("transport", "http://schemas.xmlsoap.org/soap/" + endpointURI.getScheme());
+        }
+    }
+
+    private void transformAddress(Element element, ExecutionContext executionContext) {
+        URI endpointURI = (URI) executionContext.getAttribute(ENDPOINT_URI);
+        if(endpointURI != null) {
+            // Make sure there's a path (if only a single slash).  JBossWS client code will
+            // fail because of a feature of JBossRemoting.  See http://jira.jboss.com/jira/browse/JBWS-1802
+            if(endpointURI.getPath() == null || endpointURI.getPath().equals("")) {
+                try {
+                    endpointURI = new URI(endpointURI.getScheme(), endpointURI.getUserInfo(),
+                            endpointURI.getHost(), endpointURI.getPort(), "/", endpointURI.getQuery(), endpointURI.getFragment());
+                } catch (URISyntaxException e) {
+                    logger.error("Failed to properly format endpoint location URL '" + endpointURI.toString() + "'.  Failed to add single slash character for path.  This may cause JBossWS Client code to fail.");
+                }
+            }
+            
+            element.setAttribute("location", endpointURI.toString());
+        }
+    }
+}

Deleted: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlTransformer.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlTransformer.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlTransformer.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -1,112 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.actions.soap;
-
-import org.milyn.delivery.dom.DOMElementVisitor;
-import org.milyn.container.ExecutionContext;
-import org.milyn.SmooksException;
-import org.milyn.xml.DomUtils;
-import org.milyn.cdr.SmooksResourceConfiguration;
-import org.milyn.cdr.SmooksConfigurationException;
-import org.w3c.dom.Element;
-import org.apache.log4j.Logger;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * Smooks transformer for transforming the WSDL for ESB endpoints.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class WsdlTransformer implements DOMElementVisitor {
-
-    private static Logger logger = Logger.getLogger(WsdlTransformer.class);
-
-    public static final String ENDPOINT_URI = "endpointURI";
-    public static final String TARGET_CAT = "targetServiceCat";
-    public static final String TARGET_NAME = "targetServiceName";
-    public static final String TARGET_PROTOCOL = "targetProtocol";
-
-    public void setConfiguration(SmooksResourceConfiguration smooksResourceConfiguration) throws SmooksConfigurationException {
-    }
-
-    public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
-    }
-
-    public void visitAfter(Element element, ExecutionContext executionContext) throws SmooksException {
-        String elementName = DomUtils.getName(element);
-
-        if(elementName.equals("import")) {
-            transformImport(element, executionContext);
-        } else if(elementName.equals("binding")) {
-            transformBinding(element, executionContext);
-        } else if(elementName.equals("address")) {
-            transformAddress(element, executionContext);
-        }
-    }
-
-    private void transformImport(Element element, ExecutionContext executionContext) {
-        String location = DomUtils.getAttributeValue(element, "location");
-
-        if(location != null) {
-            try {
-                URI locationURI = new URI(location);
-                String targetServiceCat = (String) executionContext.getAttribute(WsdlTransformer.TARGET_CAT);
-                String targetServiceName = (String) executionContext.getAttribute(WsdlTransformer.TARGET_NAME);
-                String targetProtocol = (String) executionContext.getAttribute(WsdlTransformer.TARGET_PROTOCOL);
-                String addParams = "serviceCat=" + targetServiceCat + "&serviceName=" + targetServiceName + "&protocol=" + targetProtocol;
-
-                if(locationURI.getQuery() != null) {
-                    element.setAttribute("location", (locationURI.toString() + "&" + addParams).replace("&", "&amp;"));
-                } else {
-                    element.setAttribute("location", (locationURI.toString() + "?" + addParams).replace("&", "&amp;"));
-                }
-            } catch (URISyntaxException e) {
-                logger.info("Not processing WSDL import '" + location + "'.  Invalid URI.");
-            }
-        }
-    }
-
-    private void transformBinding(Element element, ExecutionContext executionContext) {
-        URI endpointURI = (URI) executionContext.getAttribute(ENDPOINT_URI);
-        if(endpointURI != null) {
-            element.setAttribute("transport", "http://schemas.xmlsoap.org/soap/" + endpointURI.getScheme());
-        }
-    }
-
-    private void transformAddress(Element element, ExecutionContext executionContext) {
-        URI endpointURI = (URI) executionContext.getAttribute(ENDPOINT_URI);
-        if(endpointURI != null) {
-            // Make sure there's a path (if only a single slash).  JBossWS client code will
-            // fail because of a feature of JBossRemoting.  See http://jira.jboss.com/jira/browse/JBWS-1802
-            if(endpointURI.getPath() == null || endpointURI.getPath().equals("")) {
-                try {
-                    endpointURI = new URI(endpointURI.getScheme(), endpointURI.getUserInfo(),
-                            endpointURI.getHost(), endpointURI.getPort(), "/", endpointURI.getQuery(), endpointURI.getFragment());
-                } catch (URISyntaxException e) {
-                    logger.error("Failed to properly format endpoint location URL '" + endpointURI.toString() + "'.  Failed to add single slash character for path.  This may cause JBossWS Client code to fail.");
-                }
-            }
-            
-            element.setAttribute("location", endpointURI.toString());
-        }
-    }
-}

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -44,6 +44,8 @@
 import org.jboss.soa.esb.listeners.message.MessageDeliverException;
 import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.message.MessagePayloadProxy;
+import org.jboss.internal.soa.esb.publish.Publish;
+import org.apache.log4j.Logger;
 
 /**
  * SOAP Client action processor. <p/> Uses the Wise Client Service to generate JAXWS client class and call the target service.
@@ -153,6 +155,7 @@
  * 
  * @author <a href="mailto:stefano.maestri at javalinux.it">stefano.maestri at javalinux.it</a>
  */
+ at Publish(WiseWsdlContractPublisher.class)
 public class SOAPClient extends AbstractActionPipelineProcessor {
 
     private final Logger logger = Logger.getLogger(SOAPClient.class);

Copied: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java (from rev 25124, labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java)
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import org.jboss.soa.esb.listeners.config.Action;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.soap.AbstractWsdlContractPublisher;
+import org.jboss.soa.esb.actions.soap.WsdlContractPublisher;
+
+import java.util.Properties;
+
+/**
+ * WSDL contract publisher.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class WiseWsdlContractPublisher extends WsdlContractPublisher {
+
+    public Properties getHttpClientProperties() {
+        Properties httpClientProperties = (Properties) getProperties().clone();
+        String configurators = httpClientProperties.getProperty("configurators");
+
+        // Handle potential Http BASIC Auth....
+        if(httpClientProperties.containsKey("username")) {
+            httpClientProperties.setProperty("auth-username", httpClientProperties.getProperty("username"));
+            if(httpClientProperties.containsKey("password")) {
+                httpClientProperties.setProperty("auth-password", httpClientProperties.getProperty("password"));
+            }
+
+            // Only auto-configure the configurators if they're not already configured.
+            // If they're configured in any way at all, we don't modify that.  If they're
+            // not configured and a username/password is supplied, we assume BASIC Auth...
+            if(configurators == null) {
+                configurators = "AuthBASIC";
+            }
+        }
+
+        if(configurators == null) {
+            httpClientProperties.setProperty("configurators", configurators);
+        }
+
+        return httpClientProperties;
+    }
+}
\ No newline at end of file

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/main/resources/org/jboss/soa/esb/actions/soap/wsdltrans.xml	2009-02-19 04:47:05 UTC (rev 25332)
@@ -2,15 +2,15 @@
 <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
 
     <resource-config selector="import">
-        <resource>org.jboss.soa.esb.actions.soap.WsdlTransformer</resource>
+        <resource>org.jboss.soa.esb.actions.soap.WsdlEndpointTransformer</resource>
     </resource-config>
 
     <resource-config selector="port address" selector-namespace="http://schemas.xmlsoap.org/wsdl/soap/">
-        <resource>org.jboss.soa.esb.actions.soap.WsdlTransformer</resource>
+        <resource>org.jboss.soa.esb.actions.soap.WsdlEndpointTransformer</resource>
     </resource-config>
 
     <resource-config selector="binding" selector-namespace="http://schemas.xmlsoap.org/wsdl/soap/">
-        <resource>org.jboss.soa.esb.actions.soap.WsdlTransformer</resource>
+        <resource>org.jboss.soa.esb.actions.soap.WsdlEndpointTransformer</resource>
     </resource-config>
 
     <!--

Modified: labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java	2009-02-19 02:11:49 UTC (rev 25331)
+++ labs/jbossesb/branches/JBESB_4_4_GA_FP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java	2009-02-19 04:47:05 UTC (rev 25332)
@@ -39,40 +39,40 @@
 	private Logger log = Logger .getLogger( JBossWSAdapterContractPublisherUnitTest.class );
 	
     public void test() throws ConfigurationException, IOException, SAXException {
-        WebserviceContractPublisher publisher = new WebserviceContractPublisher();
+        JBossWSWebserviceContractPublisher publisher = new JBossWSWebserviceContractPublisher();
         String wsdlIn = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-in.wsdl")));
         String wsdlOutExpected = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-out-expected.wsdl")));
         EPR epr = new EPR(URI.create("socket://x.y.x:8989/"));
 
-        publisher.initializeTransform();
+        publisher.initializeEndpointRewriteTransformer();
         String wsdlOut = publisher.updateWsdl(wsdlIn, epr, "myServiceCat", "myServiceName", "socket");
         log.debug(wsdlOut);
         assertTrue("WSDL Update failed.  \n\n*** Expected:\n\n" + wsdlOutExpected + "\n\n*** Got:\n\n" + wsdlOut, StringUtils.equalsIgnoreLinebreaks(wsdlOutExpected, wsdlOut, false));
     }
 
     public void test_http_rewrite() throws ConfigurationException, IOException, SAXException {
-        WebserviceContractPublisher publisher = new WebserviceContractPublisher();
+        JBossWSWebserviceContractPublisher publisher = new JBossWSWebserviceContractPublisher();
         String wsdlIn = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-in.wsdl")));
         String wsdlOutExpected = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-out-expected-http-rewrite.wsdl")));
         EPR epr = new EPR(URI.create("http://x.y.x:8989/"));
 
         publisher.setActionConfig(buildActionConfig(true));
 
-        publisher.initializeTransform();
+        publisher.initializeEndpointRewriteTransformer();
         String wsdlOut = publisher.updateWsdl(wsdlIn, epr, "myServiceCat", "myServiceName", "http");
         log.debug(wsdlOut);
         assertTrue("WSDL Update failed.  \n\n*** Expected:\n\n" + wsdlOutExpected + "\n\n*** Got:\n\n" + wsdlOut, StringUtils.equalsIgnoreLinebreaks(wsdlOutExpected, wsdlOut, false));
     }
 
     public void test_http_norewrite() throws ConfigurationException, IOException, SAXException {
-        WebserviceContractPublisher publisher = new WebserviceContractPublisher();
+        JBossWSWebserviceContractPublisher publisher = new JBossWSWebserviceContractPublisher();
         String wsdlIn = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-in.wsdl")));
         String wsdlOutExpected = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-in.wsdl"))); // expected same as input wsdl
         EPR epr = new EPR(URI.create("http://x.y.x:8989/"));
 
         publisher.setActionConfig(buildActionConfig(false));
         
-        publisher.initializeTransform();
+        publisher.initializeEndpointRewriteTransformer();
         String wsdlOut = publisher.updateWsdl(wsdlIn, epr, "myServiceCat", "myServiceName", "http");
         log.debug(wsdlOut);
         assertTrue("WSDL Update failed.  \n\n*** Expected:\n\n" + wsdlOutExpected + "\n\n*** Got:\n\n" + wsdlOut, StringUtils.equalsIgnoreLinebreaks(wsdlOutExpected, wsdlOut, false));
@@ -82,7 +82,7 @@
         final Properties properties = new Properties() ;
 
         properties.put(SOAPProcessor.JBOSSWS_ENDPOINT, "BlahEndpoint");
-        properties.put(SOAPProcessor.REWRITE_ENDPOINT_URL, Boolean.toString(rewriteUrls));
+        properties.put(AbstractWsdlContractPublisher.REWRITE_ENDPOINT_URL, Boolean.toString(rewriteUrls));
         
         return new Action("name", "class", "process", properties) ;
     }




More information about the jboss-svn-commits mailing list