public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
try {
OMOutputFormat format = new OMOutputFormat();
// if (!msgContext.isDoingMTOM())
msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext));
msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext));
msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext));
format.setSOAP11(msgContext.isSOAP11());
format.setDoOptimize(msgContext.isDoingMTOM());
format.setDoingSWA(msgContext.isDoingSwA());
format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext));
Object mimeBoundaryProperty = msgContext
.getProperty(Constants.Configuration.MIME_BOUNDARY);
if (mimeBoundaryProperty != null) {
format.setMimeBoundary((String) mimeBoundaryProperty);
}
TransportOutDescription transportOut = msgContext.getConfigurationContext().
getAxisConfiguration().getTransportOut(Constants.TRANSPORT_HTTP);
// set the timeout properteies
Parameter soTimeoutParam = transportOut.getParameter(HTTPConstants.SO_TIMEOUT);
Parameter connTimeoutParam = transportOut.getParameter(HTTPConstants.CONNECTION_TIMEOUT);
// set the property valuse only if they are not set by the user explicitly
if ((soTimeoutParam != null) && (msgContext.getProperty(HTTPConstants.SO_TIMEOUT) == null)) {
msgContext.setProperty(HTTPConstants.SO_TIMEOUT, new Integer((String)soTimeoutParam.getValue()));
}
if ((connTimeoutParam != null) && (msgContext.getProperty(HTTPConstants.CONNECTION_TIMEOUT) == null)) {
msgContext.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer((String)connTimeoutParam.getValue()));
}
//if a parameter has set been set, we will omit the SOAP action for SOAP 1.2
if (transportOut != null) {
if (!msgContext.isSOAP11()) {
Parameter param = transportOut.getParameter(HTTPConstants.OMIT_SOAP_12_ACTION);
Object parameterValue = null;
if (param != null) {
parameterValue = param.getValue();
}
if (parameterValue != null && JavaUtils.isTrueExplicitly(parameterValue)) {
//Check whether user has already overridden this.
Object propertyValue = msgContext.getProperty(Constants.Configuration.DISABLE_SOAP_ACTION);
if (propertyValue == null || !JavaUtils.isFalseExplicitly(propertyValue)) {
msgContext.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION,
Boolean.TRUE);
}
}
}
}
// Transport URL can be different from the WSA-To. So processing
// that now.
EndpointReference epr = null;
String transportURL = (String) msgContext
.getProperty(Constants.Configuration.TRANSPORT_URL);
if (transportURL != null) {
epr = new EndpointReference(transportURL);
} else if (msgContext.getTo() != null
&& !msgContext.getTo().hasAnonymousAddress()) {
epr = msgContext.getTo();
}
// Check for the REST behavior, if you desire rest behavior
// put a < parameter name="doREST" value="true"/ > at the
// server.xml/client.xml file
// ######################################################
// Change this place to change the wsa:toepr
// epr = something
// ######################################################
if (epr != null) {
if (!epr.hasNoneAddress()) {
writeMessageWithCommons(msgContext, epr, format);
}else{
if(msgContext.isFault()){
if(log.isDebugEnabled()){
log.debug("Fault sent to WS-A None URI: "+msgContext.getEnvelope().getBody().getFault());
}
}
}
} else {
if (msgContext.getProperty(MessageContext.TRANSPORT_OUT) != null) {
sendUsingOutputStream(msgContext, format);
TransportUtils.setResponseWritten(msgContext, true);
} else {
throw new AxisFault("Both the TO and MessageContext.TRANSPORT_OUT property " +
"are null, so nowhere to send");
}
}
} catch (FactoryConfigurationError e) {
log.debug(e);
throw AxisFault.makeFault(e);
} catch (IOException e) {
log.debug(e);
throw AxisFault.makeFault(e);
}
return InvocationResponse.CONTINUE;
}
|