You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2009/03/09 22:41:38 UTC
svn commit: r751856 - in /ode/trunk:
axis2-war/src/test/resources/TestEndpointProperties/
axis2-war/src/test/resources/TestSoapHeader/
axis2/src/main/java/org/apache/ode/axis2/
axis2/src/main/java/org/apache/ode/axis2/httpbinding/
axis2/src/main/java/o...
Author: midon
Date: Mon Mar 9 21:41:37 2009
New Revision: 751856
URL: http://svn.apache.org/viewvc?rev=751856&view=rev
Log:
ODE-547: make the endpoint address overridable
Added:
ode/trunk/axis2-war/src/test/resources/TestSoapHeader/location.endpoint
Modified:
ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl
ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint
ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint
ode/trunk/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Properties.java
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/soapbinding/SoapExternalService.java
Modified: ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl (original)
+++ ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl Mon Mar 9 21:41:37 2009
@@ -88,7 +88,9 @@
<wsdl:service name="PropertiesService">
<wsdl:port name="PropertiesPort" binding="tns:binding">
- <http:address location="http://localhost:7070/EchoService/"/>
+ <!-- Intentionally invalid location.
+ For test purpose, the location must be set from test-endpoint-properties_global_conf.endpoint -->
+ <http:address location="http://invalid.address"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Modified: ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint (original)
+++ ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint Mon Mar 9 21:41:37 2009
@@ -1,4 +1,7 @@
alias.myns1=http://ode/bpel/test/properties
-myns1.PropertiesService.ode.http.default-headers.header_BB=from_deployment_unit#file1
\ No newline at end of file
+myns1.PropertiesService.ode.http.default-headers.header_BB=from_deployment_unit#file1
+
+# this location must be overridden by the test-endpoint-properties_global_conf.endpoint
+myns1.PropertiesService.ode.address=http://localhost:7070/AnInvalidPath
\ No newline at end of file
Modified: ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint (original)
+++ ode/trunk/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint Mon Mar 9 21:41:37 2009
@@ -4,4 +4,6 @@
myns1.PropertiesService.ode.http.default-headers.header_A=from_global_conf_directory_only
myns1.PropertiesService.ode.http.default-headers.header_ABC=from_global_conf_directory_ABC
myns.PropertiesService.ode.http.default-headers.header_AB=from_global_conf_directory_AB
-myns1.PropertiesService.ode.http.default-headers.header_AC=from_global_conf_directory_AC
\ No newline at end of file
+myns1.PropertiesService.ode.http.default-headers.header_AC=from_global_conf_directory_AC
+
+myns1.PropertiesService.ode.address=http://localhost:7070/EchoService/
\ No newline at end of file
Modified: ode/trunk/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl (original)
+++ ode/trunk/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl Mon Mar 9 21:41:37 2009
@@ -146,15 +146,21 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="DummyService">
- <wsdl:port name="DummyServiceSOAP11port_http" binding="ns1:DummyServiceSOAP11Binding">
- <soap:address location="http://localhost:8888/processes/DummyService"/>
- </wsdl:port>
- <wsdl:port name="DummyServiceSOAP12port_http" binding="ns1:DummyServiceSOAP12Binding">
- <soap12:address location="http://localhost:8888/processes/DummyService"/>
- </wsdl:port>
- <wsdl:port name="DummyServiceHttpport" binding="ns1:DummyServiceHttpBinding">
- <http:address location="http://localhost:8888/processes/DummyService"/>
- </wsdl:port>
- </wsdl:service>
+ <wsdl:service name="DummyService">
+ <wsdl:port name="DummyServiceSOAP11port_http" binding="ns1:DummyServiceSOAP11Binding">
+ <!-- Intentionally invalid location.
+ For test purpose, the location must be set from config.endpoint -->
+ <soap:address location="http://invalid.address"/>
+ </wsdl:port>
+ <wsdl:port name="DummyServiceSOAP12port_http" binding="ns1:DummyServiceSOAP12Binding">
+ <!-- Intentionally invalid location.
+ For test purpose, the location must be set from config.endpoint -->
+ <soap12:address location="http://invalid.address"/>
+ </wsdl:port>
+ <wsdl:port name="DummyServiceHttpport" binding="ns1:DummyServiceHttpBinding">
+ <!-- Intentionally invalid location.
+ For test purpose, the location must be set from config.endpoint -->
+ <http:address location="http://invalid.address"/>
+ </wsdl:port>
+ </wsdl:service>
</wsdl:definitions>
\ No newline at end of file
Added: ode/trunk/axis2-war/src/test/resources/TestSoapHeader/location.endpoint
URL: http://svn.apache.org/viewvc/ode/trunk/axis2-war/src/test/resources/TestSoapHeader/location.endpoint?rev=751856&view=auto
==============================================================================
--- ode/trunk/axis2-war/src/test/resources/TestSoapHeader/location.endpoint (added)
+++ ode/trunk/axis2-war/src/test/resources/TestSoapHeader/location.endpoint Mon Mar 9 21:41:37 2009
@@ -0,0 +1,3 @@
+
+alias.myns=http://axis2.ode.apache.org
+myns.DummyService.ode.address=http://localhost:8888/processes/DummyService
\ No newline at end of file
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Properties.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Properties.java?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Properties.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/Properties.java Mon Mar 9 21:41:37 2009
@@ -70,6 +70,11 @@
*/
public static final String PROP_HTTP_PROTOCOL_ENCODING = "http.protocol.encoding";
+ /**
+ * Property to override the location set in soap:address or http:address
+ */
+ public static final String PROP_ADDRESS = "address";
+
// Httpclient specific
public static final String PROP_HTTP_MAX_REDIRECTS = HttpClientParams.MAX_REDIRECTS;
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java Mon Mar 9 21:41:37 2009
@@ -32,6 +32,7 @@
import org.apache.ode.axis2.ExternalService;
import org.apache.ode.axis2.ODEService;
import org.apache.ode.axis2.Properties;
+import org.apache.ode.axis2.OdeFault;
import org.apache.ode.bpel.iapi.BpelServer;
import org.apache.ode.bpel.iapi.EndpointReference;
import org.apache.ode.bpel.iapi.Message;
@@ -40,8 +41,8 @@
import org.apache.ode.bpel.iapi.ProcessConf;
import org.apache.ode.il.epr.EndpointFactory;
import org.apache.ode.il.epr.WSAEndpoint;
+import org.apache.ode.il.epr.MutableEndpoint;
import org.apache.ode.utils.DOMUtils;
-import static org.apache.ode.utils.http.StatusCode.*;
import org.apache.ode.utils.wsdl.Messages;
import org.apache.ode.utils.wsdl.WsdlUtils;
import org.w3c.dom.Element;
@@ -57,6 +58,8 @@
import java.util.Map;
import java.util.Collections;
import java.util.concurrent.Callable;
+import java.net.URL;
+import java.net.MalformedURLException;
/**
@@ -78,8 +81,9 @@
protected WSAEndpoint endpointReference;
protected Binding portBinding;
+ private URL endpointUrl;
- public HttpExternalService(ProcessConf pconf, QName serviceName, String portName, BpelServer server, MultiThreadedHttpConnectionManager connManager) {
+ public HttpExternalService(ProcessConf pconf, QName serviceName, String portName, BpelServer server, MultiThreadedHttpConnectionManager connManager) throws OdeFault {
if (log.isDebugEnabled())
log.debug("new HTTP External service, service name=[" + serviceName + "]; port name=[" + portName + "]");
this.portName = portName;
@@ -110,6 +114,11 @@
if (eprElmt == null)
throw new IllegalArgumentException(msgs.msgPortDefinitionNotFound(serviceName, portName));
endpointReference = EndpointFactory.convertToWSA(ODEService.createServiceRef(eprElmt));
+ try {
+ endpointUrl = new URL(endpointReference.getUrl());
+ } catch (MalformedURLException e) {
+ throw new OdeFault(e);
+ }
httpMethodConverter = new HttpMethodConverter(definition, serviceName, portName);
connections = connManager;
@@ -138,8 +147,23 @@
final Map<String, String> properties = pconf.getEndpointProperties(endpointReference);
final HttpParams params = Properties.HttpClient.translate(properties);
+ // base baseUrl
+ String mexEndpointUrl = ((MutableEndpoint) odeMex.getEndpointReference()).getUrl();
+ String baseUrl = mexEndpointUrl;
+ // The endpoint URL might be overridden from the properties file(s)
+ // The order of precedence is (in descending order): process, property, wsdl.
+ if(endpointUrl.equals(new URL(mexEndpointUrl))){
+ String address = (String) params.getParameter(Properties.PROP_ADDRESS);
+ if(address!=null) {
+ if (log.isDebugEnabled()) log.debug("Endpoint URL overridden by property files. "+mexEndpointUrl+" => "+address);
+ baseUrl = address;
+ }
+ }else{
+ if (log.isDebugEnabled()) log.debug("Endpoint URL overridden by process. "+endpointUrl+" => "+mexEndpointUrl);
+ }
+
// build the http method
- final HttpMethod method = httpMethodConverter.createHttpRequest(odeMex, params);
+ final HttpMethod method = httpMethodConverter.createHttpRequest(odeMex, params, baseUrl);
// create a client
HttpClient client = new HttpClient(connections);
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java Mon Mar 9 21:41:37 2009
@@ -30,7 +30,6 @@
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HostParams;
import org.apache.commons.httpclient.params.HttpParams;
-import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -38,7 +37,6 @@
import org.apache.ode.axis2.util.URLEncodedTransformer;
import org.apache.ode.axis2.util.UrlReplacementTransformer;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
-import org.apache.ode.il.epr.MutableEndpoint;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.Namespaces;
import org.apache.ode.utils.http.HttpUtils;
@@ -46,10 +44,10 @@
import static org.apache.ode.utils.http.StatusCode._202_ACCEPTED;
import org.apache.ode.utils.wsdl.Messages;
import org.apache.ode.utils.wsdl.WsdlUtils;
+import org.apache.ode.il.epr.MutableEndpoint;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
@@ -92,6 +90,10 @@
public HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex, HttpParams params) throws UnsupportedEncodingException {
+ return createHttpRequest(odeMex, params, ((MutableEndpoint) odeMex.getEndpointReference()).getUrl());
+ }
+
+ public HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex, HttpParams params, String baseUrl) throws UnsupportedEncodingException {
Operation operation = odeMex.getOperation();
BindingOperation bindingOperation = binding.getBindingOperation(operation.getName(), operation.getInput().getName(), operation.getOutput().getName());
@@ -99,9 +101,6 @@
Element message = odeMex.getRequest().getMessage();
Message msgDef = operation.getInput().getMessage();
- // base url
- String url = ((MutableEndpoint) odeMex.getEndpointReference()).getUrl();
-
// extract part values into a map and check that all parts are assigned a value
Map<String, Element> partElements = extractPartElements(msgDef, message);
@@ -110,7 +109,7 @@
String verb = WsdlUtils.resolveVerb(binding, bindingOperation);
// build the http method itself
- HttpMethod method = prepareHttpMethod(bindingOperation, verb, partElements, odeMex.getRequest().getHeaderParts(), url, params);
+ HttpMethod method = prepareHttpMethod(bindingOperation, verb, partElements, odeMex.getRequest().getHeaderParts(), baseUrl, params);
return method;
}
Modified: ode/trunk/axis2/src/main/java/org/apache/ode/axis2/soapbinding/SoapExternalService.java
URL: http://svn.apache.org/viewvc/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/soapbinding/SoapExternalService.java?rev=751856&r1=751855&r2=751856&view=diff
==============================================================================
--- ode/trunk/axis2/src/main/java/org/apache/ode/axis2/soapbinding/SoapExternalService.java (original)
+++ ode/trunk/axis2/src/main/java/org/apache/ode/axis2/soapbinding/SoapExternalService.java Mon Mar 9 21:41:37 2009
@@ -40,6 +40,7 @@
import org.apache.ode.axis2.ExternalService;
import org.apache.ode.axis2.ODEService;
import org.apache.ode.axis2.Properties;
+import org.apache.ode.axis2.OdeFault;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MessageExchange;
import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
@@ -67,6 +68,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.net.URL;
+import java.net.MalformedURLException;
import java.util.Map;
/**
@@ -94,6 +97,7 @@
private AxisConfiguration _axisConfig;
private SoapMessageConverter _converter;
private ProcessConf _pconf;
+ private URL endpointUrl;
public SoapExternalService(Definition definition, QName serviceName, String portName,
AxisConfiguration axisConfig, ProcessConf pconf, MultiThreadedHttpConnectionManager connManager) throws AxisFault {
@@ -108,7 +112,7 @@
_axisServiceWatchDog = WatchDog.watchFile(fileToWatch, new ServiceFileObserver(fileToWatch));
_axisOptionsWatchDog = new WatchDog<Map, OptionsObserver>(new EndpointPropertiesMutable(), new OptionsObserver());
_configContext = new ConfigurationContext(_axisConfig);
- _configContext.setProperty(HTTPConstants.MUTTITHREAD_HTTP_CONNECTION_MANAGER, connManager);
+ _configContext.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, connManager);
// make sure the client is not shared, see also org.apache.ode.axis2.Properties.Axis2
_configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "false");
@@ -117,6 +121,11 @@
if (eprElmt == null)
throw new IllegalArgumentException(msgs.msgPortDefinitionNotFound(serviceName, portName));
endpointReference = EndpointFactory.convertToWSA(ODEService.createServiceRef(eprElmt));
+ try {
+ endpointUrl = new URL(endpointReference.getUrl());
+ } catch (MalformedURLException e) {
+ throw new OdeFault(e);
+ }
}
public void invoke(final PartnerRoleMessageExchange odeMex) {
@@ -138,7 +147,22 @@
_converter.createSoapRequest(mctx, odeMex.getRequest(), odeMex.getOperation());
SOAPEnvelope soapEnv = mctx.getEnvelope();
- EndpointReference axisEPR = new EndpointReference(((MutableEndpoint) odeMex.getEndpointReference()).getUrl());
+ String mexEndpointUrl = ((MutableEndpoint) odeMex.getEndpointReference()).getUrl();
+
+ EndpointReference axisEPR = new EndpointReference(mexEndpointUrl);
+ // The endpoint URL might be overridden from the properties file(s)
+ // The order of precedence is (in descending order): process, property, wsdl.
+ if (endpointUrl.equals(new URL(mexEndpointUrl))) {
+ String address = (String) client.getOptions().getProperty(Properties.PROP_ADDRESS);
+ if (address != null) {
+ if (__log.isDebugEnabled())
+ __log.debug("Endpoint URL overridden by property files. " + mexEndpointUrl + " => " + address);
+ axisEPR.setAddress(address);
+ }
+ } else {
+ if (__log.isDebugEnabled())
+ __log.debug("Endpoint URL overridden by process. " + endpointUrl + " => " + mexEndpointUrl);
+ }
if (__log.isDebugEnabled()) {
__log.debug("Axis2 sending message to " + axisEPR.getAddress() + " using MEX " + odeMex);
__log.debug("Message: " + soapEnv);