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:24:04 UTC
svn commit: r751847 - in /ode/branches/APACHE_ODE_1.X:
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/
Author: midon
Date: Mon Mar 9 21:24:03 2009
New Revision: 751847
URL: http://svn.apache.org/viewvc?rev=751847&view=rev
Log:
ODE-547: make the endpoint address overridable
Added:
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/location.endpoint
Modified:
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
Modified: ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl (original)
+++ ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/Echo.wsdl Mon Mar 9 21:24:03 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/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint (original)
+++ ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties-deploy-unit_headerBB_1.endpoint Mon Mar 9 21:24:03 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/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint (original)
+++ ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestEndpointProperties/test-endpoint-properties_global_conf.endpoint Mon Mar 9 21:24:03 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/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl (original)
+++ ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/dummy-service.wsdl Mon Mar 9 21:24:03 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/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/location.endpoint
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/location.endpoint?rev=751847&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/location.endpoint (added)
+++ ode/branches/APACHE_ODE_1.X/axis2-war/src/test/resources/TestSoapHeader/location.endpoint Mon Mar 9 21:24:03 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/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java Mon Mar 9 21:24:03 2009
@@ -69,6 +69,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/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java Mon Mar 9 21:24:03 2009
@@ -68,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;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
@@ -101,6 +103,7 @@
private Scheduler _sched;
private BpelServer _server;
private ProcessConf _pconf;
+ private URL endpointUrl;
public SoapExternalService(ProcessConf pconf, QName serviceName, String portName, ExecutorService executorService,
AxisConfiguration axisConfig, Scheduler sched, BpelServer server, MultiThreadedHttpConnectionManager connManager) throws AxisFault {
@@ -127,6 +130,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) {
@@ -147,8 +155,21 @@
_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);
@@ -221,9 +242,9 @@
});
odeMex.replyOneWayOk();
}
- } catch (AxisFault axisFault) {
+ } catch (Exception ex) {
String errmsg = "Error sending message to Axis2 for ODE mex " + odeMex;
- __log.error(errmsg, axisFault);
+ __log.error(errmsg, ex);
odeMex.replyWithFailure(MessageExchange.FailureType.COMMUNICATION_ERROR, errmsg, null);
}
}
Modified: ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpExternalService.java Mon Mar 9 21:24:03 2009
@@ -24,16 +24,15 @@
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.params.HttpParams;
-import org.apache.commons.httpclient.params.DefaultHttpParams;
-import org.apache.commons.httpclient.params.HostParams;
-import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.epr.EndpointFactory;
import org.apache.ode.bpel.epr.WSAEndpoint;
+import org.apache.ode.bpel.epr.MutableEndpoint;
import org.apache.ode.bpel.iapi.BpelServer;
import org.apache.ode.bpel.iapi.EndpointReference;
import org.apache.ode.bpel.iapi.Message;
@@ -42,7 +41,6 @@
import org.apache.ode.bpel.iapi.ProcessConf;
import org.apache.ode.bpel.iapi.Scheduler;
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;
@@ -56,9 +54,10 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
-import java.util.Collections;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
+import java.net.URL;
+import java.net.MalformedURLException;
/**
@@ -82,10 +81,11 @@
protected HttpMethodConverter httpMethodConverter;
protected Binding portBinding;
+ private URL endpointUrl;
public HttpExternalService(ProcessConf pconf, QName serviceName, String portName,
ExecutorService executorService, Scheduler scheduler, BpelServer server,
- MultiThreadedHttpConnectionManager connManager) {
+ MultiThreadedHttpConnectionManager connManager) throws OdeFault {
if (log.isDebugEnabled())
log.debug("new HTTP External service, service name=[" + serviceName + "]; port name=[" + portName + "]");
this.portName = portName;
@@ -117,6 +117,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;
@@ -145,8 +150,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/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java?rev=751847&r1=751846&r2=751847&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java Mon Mar 9 21:24:03 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;
@@ -91,7 +90,7 @@
}
- public HttpMethod createHttpRequest(PartnerRoleMessageExchange odeMex, HttpParams params) throws UnsupportedEncodingException {
+ 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 +98,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 +106,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;
}