[jboss-svn-commits] JBL Code SVN: r37941 - in labs/jbossesb/trunk/product/services/soap/src: test/java/org/jboss/soa/esb/actions/soap/wise and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Mar 27 00:45:29 EDT 2012
Author: tcunning
Date: 2012-03-27 00:45:28 -0400 (Tue, 27 Mar 2012)
New Revision: 37941
Modified:
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java
Log:
JBESB-3765
Incorporate WISE client property substitution patch.
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2012-03-26 23:01:16 UTC (rev 37940)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2012-03-27 04:45:28 UTC (rev 37941)
@@ -36,6 +36,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import javax.jws.Oneway;
import javax.xml.ws.handler.Handler;
@@ -47,6 +48,8 @@
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
@@ -187,9 +190,19 @@
private boolean continueOnFault = false;
private WSDynamicClient client;
+ private Properties wiseProps = null;
public SOAPClient(final ConfigTree config ) throws ConfigurationException
{
+ // Check for action-configured Wise information
+ ConfigTree[] wiseConfig = config.getChildren("wise-config");
+ if(wiseConfig.length == 1) {
+ wiseProps = new Properties();
+ for(ConfigTree node : wiseConfig[0].getChildren("wise-property")) {
+ wiseProps.setProperty(node.getRequiredAttribute("name"), node.getRequiredAttribute("value"));
+ }
+ }
+
wsdl = config.getRequiredAttribute("wsdl");
soapAction = config.getAttribute("SOAPAction");
endPointName = config.getRequiredAttribute("EndPointName");
@@ -311,7 +324,13 @@
{
try
{
- client = new WSDynamicClientFactory().create(wsdl, serviceName, username, password);
+ final String propertySubstitution = ModulePropertyManager.getPropertyManager(
+ ModulePropertyManager.TRANSPORTS_MODULE).getProperty(Environment.WS_PROPERTY_SUBSTITUTION);
+ if (wiseProps != null) {
+ client = new WSDynamicClientFactory().create(wsdl, serviceName, username, password, wiseProps);
+ } else {
+ client = new WSDynamicClientFactory().create(wsdl, serviceName, username, password);
+ }
}
catch (final WiseException e)
{
@@ -459,7 +478,7 @@
}
return message;
}
-
+
private WiseMapper createSmooksMapper(final String url)
throws ConfigurationException
{
@@ -476,7 +495,8 @@
@Override
public String toString()
{
- return "Wise SOAPClient [wsdl=" + wsdl + ", soapAction=" + soapAction + ", endPointName=" + endPointName + ", serviceName=" + serviceName + ", smooksRequestMapperURL=" + smooksRequestMapperURL + ", smooksResponseMapperURL=" + smooksResponseMapperURL + "]";
+ return "Wise SOAPClient [wsdl=" + wsdl + ", soapAction=" + soapAction + ", endPointName=" + endPointName + ", serviceName=" + serviceName + ", smooksRequestMapperURL=" + smooksRequestMapperURL + ", smooksResponseMapperURL=" + smooksResponseMapperURL
+ + ", wiseProps=" + wiseProps.toString() + "] ";
}
String getOperationName()
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java 2012-03-26 23:01:16 UTC (rev 37940)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java 2012-03-27 04:45:28 UTC (rev 37941)
@@ -29,6 +29,9 @@
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.util.Enumeration;
+import java.util.Properties;
+
import org.apache.commons.lang.StringUtils;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
import sun.misc.BASE64Encoder;
@@ -73,6 +76,34 @@
return client;
}
+ public synchronized WSDynamicClient create(final String wsdl, final String name, final String username,
+ final String password, Properties props) throws WiseException {
+ AssertArgument.isNotNull(name, "name");
+ AssertArgument.isNotNull(wsdl, "wsdl");
+
+ final WiseProperties wiseProperties = WiseProperties.newInstance("");
+
+ // Override with additional properties
+ if (props != null)
+ {
+ for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();)
+ {
+ String propname = (String) e.nextElement();
+ wiseProperties.setProperty(propname, props.getProperty(propname));
+ }
+ }
+
+ String usableWsdl = wsdl;
+ if (wsdl.startsWith("http://"))
+ {
+ usableWsdl = downloadWsdl(wsdl, username, password, wiseProperties);
+ }
+
+ final WSDynamicClient client = new WSDynamicClient(wiseProperties);
+ client.init(usableWsdl, name, username, password);
+ return client;
+ }
+
private String downloadWsdl(String wsdlURL, String userName, String password, WiseProperties wiseProperties) throws WiseConnectionException
{
if (StringUtils.trimToNull(userName) == null || StringUtils.trimToNull(password) == null)
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java 2012-03-26 23:01:16 UTC (rev 37940)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java 2012-03-27 04:45:28 UTC (rev 37941)
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import it.javalinux.wise.core.client.WSDynamicClient;
import it.javalinux.wise.core.client.WSEndpoint;
import it.javalinux.wise.core.exceptions.WiseException;
@@ -108,6 +109,17 @@
assertNotNull(client.getOperationName());
assertEquals(operationName, client.getOperationName());
}
+
+ @Test
+ public void configPropSub() throws ConfigurationException, ActionProcessingException, ActionLifecycleException
+ {
+ final String operationName = "someOperation";
+ final ConfigTree config = createPropSubstitutionConfig(operationName, null);
+ final SOAPClient client = new MockSOAPClient(config);
+
+ assertTrue(client.toString().indexOf("wiseProps={foo=bar}") > 0);
+ }
+
public static junit.framework.Test suite()
{
@@ -124,6 +136,23 @@
configTree.setAttribute("operationName", operationName);
return configTree;
}
+
+ private ConfigTree createPropSubstitutionConfig(final String operationName, final String soapAction)
+ {
+ ConfigTree configTree = new ConfigTree("wise-soap-client");
+ configTree.setAttribute("wsdl", wsdl);
+ configTree.setAttribute("SOAPAction", soapAction);
+ configTree.setAttribute("EndPointName", endPointName);
+ configTree.setAttribute("serviceName", serviceName);
+ configTree.setAttribute("operationName", operationName);
+
+ ConfigTree wiseConfig = new ConfigTree("wise-config", configTree);
+ ConfigTree wiseProp = new ConfigTree("wise-property", wiseConfig);
+ wiseProp.setAttribute("name", "foo");
+ wiseProp.setAttribute("value", "bar");
+
+ return configTree;
+ }
private class MockSOAPClient extends SOAPClient
{
More information about the jboss-svn-commits
mailing list