Author: midon
Date: Wed Mar 4 00:49:40 2009
New Revision: 749865
URL: http://svn.apache.org/viewvc?rev=749865&view=rev
Log:
ODE-533: don't release the connection too early
Modified:
ode/trunk/axis2/src/main/java/org/apache/ode/axis2/soapbinding/SoapExternalService.java
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=749865&r1=749864&r2=749865&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
Wed Mar 4 00:49:40 2009
@@ -29,10 +29,7 @@
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.deployment.ServiceBuilder;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.OutOnlyAxisOperation;
-import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.*;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
@@ -131,42 +128,37 @@
// Override options are passed to the axis MessageContext so we can
// retrieve them in our session out changeHandler.
final MessageContext mctx = new MessageContext();
- /* make the given options the parent so it becomes the defaults of
the MessageContexgt. That allows the user to override
- * specific options on a given message context and not affect the
overall options.
- */
- mctx.getOptions().setParent(client.getOptions());
- writeHeader(mctx, odeMex);
-
- _converter.createSoapRequest(mctx, odeMex.getRequest(),
odeMex.getOperation());
-
- SOAPEnvelope soapEnv = mctx.getEnvelope();
- EndpointReference axisEPR = new
EndpointReference(((MutableEndpoint) odeMex.getEndpointReference()).getUrl());
- if (__log.isDebugEnabled()) {
- __log.debug("Axis2 sending message to " + axisEPR.getAddress()
+ " using MEX " + odeMex);
- __log.debug("Message: " + soapEnv);
- }
+ try {
+ /* make the given options the parent so it becomes the
defaults of the MessageContexgt. That allows the user to override
+ * specific options on a given message context and not affect
the overall options.
+ */
+ mctx.getOptions().setParent(client.getOptions());
+ writeHeader(mctx, odeMex);
- final OperationClient operationClient =
client.createClient(isTwoWay ? ServiceClient.ANON_OUT_IN_OP
- : ServiceClient.ANON_OUT_ONLY_OP);
- operationClient.addMessageContext(mctx);
- // this Options can be alter without impacting the ServiceClient
options (which is a requirement)
- Options operationOptions = operationClient.getOptions();
-
- // provide HTTP credentials if any
- AuthenticationHelper.setHttpAuthentication(odeMex,
operationOptions);
-
- operationOptions.setAction(mctx.getSoapAction());
- operationOptions.setTo(axisEPR);
+ _converter.createSoapRequest(mctx, odeMex.getRequest(),
odeMex.getOperation());
- if (isTwoWay) {
- final Operation operation = odeMex.getOperation();
+ SOAPEnvelope soapEnv = mctx.getEnvelope();
+ EndpointReference axisEPR = new
EndpointReference(((MutableEndpoint) odeMex.getEndpointReference()).getUrl());
+ if (__log.isDebugEnabled()) {
+ __log.debug("Axis2 sending message to " +
axisEPR.getAddress() + " using MEX " + odeMex);
+ __log.debug("Message: " + soapEnv);
+ }
- try {
- try {
- operationClient.execute(true);
- } finally {
- mctx.getTransportOut().getSender().cleanup(mctx);
- }
+ final OperationClient operationClient =
client.createClient(isTwoWay ? ServiceClient.ANON_OUT_IN_OP
+ : ServiceClient.ANON_OUT_ONLY_OP);
+ operationClient.addMessageContext(mctx);
+ // this Options can be alter without impacting the
ServiceClient options (which is a requirement)
+ Options operationOptions = operationClient.getOptions();
+
+ // provide HTTP credentials if any
+ AuthenticationHelper.setHttpAuthentication(odeMex,
operationOptions);
+
+ operationOptions.setAction(mctx.getSoapAction());
+ operationOptions.setTo(axisEPR);
+
+ operationClient.execute(true);
+ if (isTwoWay) {
+ final Operation operation = odeMex.getOperation();
MessageContext response =
operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
MessageContext flt =
operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE);
if (response != null && __log.isDebugEnabled())
@@ -174,19 +166,21 @@
if (flt != null) reply(odeMex, operation, flt, true);
else reply(odeMex, operation, response,
response.isFault());
- } catch (Throwable t) {
- String errmsg = "Error sending message to Axis2 for ODE
mex " + odeMex;
- __log.error(errmsg, t);
- replyWithFailure(odeMex,
MessageExchange.FailureType.COMMUNICATION_ERROR, errmsg, null);
+
+ } else { /* one-way case */
+ odeMex.replyOneWayOk();
+ }
+ } finally {
+ // make sure the HTTP connection is released to the pool!
+ TransportOutDescription out = mctx.getTransportOut();
+ if (out != null && out.getSender() != null) {
+ out.getSender().cleanup(mctx);
}
- } else /* one-way case */{
- operationClient.execute(false);
- odeMex.replyOneWayOk();
}
- } catch (AxisFault axisFault) {
+ } catch (Throwable t) {
String errmsg = "Error sending message to Axis2 for ODE mex " +
odeMex;
- __log.error(errmsg, axisFault);
-
odeMex.replyWithFailure(MessageExchange.FailureType.COMMUNICATION_ERROR,
errmsg, null);
+ __log.error(errmsg, t);
+ replyWithFailure(odeMex,
MessageExchange.FailureType.COMMUNICATION_ERROR, errmsg);
}
}
@@ -322,9 +316,9 @@
return _serviceName;
}
- private void replyWithFailure(final PartnerRoleMessageExchange odeMex,
final FailureType error, final String errmsg, final Element details) {
+ private void replyWithFailure(final PartnerRoleMessageExchange odeMex,
final FailureType error, final String errmsg) {
try {
- odeMex.replyWithFailure(error, errmsg, details);
+ odeMex.replyWithFailure(error, errmsg, null);
} catch (Exception e) {
String emsg = "Error executing replyWithFailure; reply will be
lost.";
__log.error(emsg, e);