if (log.isDebugEnabled()) {
log.debug("Enter: Call::invoke()");
}
Message reqMsg = null ;
SOAPEnvelope reqEnv = null ;
msgContext.reset();
msgContext.setResponseMessage(null);
msgContext.setProperty( MessageContext.CALL, this );
msgContext.setProperty( WSDL_SERVICE, service );
msgContext.setProperty( WSDL_PORT_NAME, getPortName() );
if ( isMsg )
msgContext.setProperty( MessageContext.IS_MSG, "true" );
if (username != null) {
msgContext.setUsername(username);
}
if (password != null) {
msgContext.setPassword(password);
}
msgContext.setMaintainSession(maintainSession);
if (operation != null) {
msgContext.setOperation(operation);
operation.setStyle(getOperationStyle());
operation.setUse(getOperationUse());
}
msgContext.setOperationStyle(getOperationStyle());
msgContext.setOperationUse(getOperationUse());
if (useSOAPAction) {
msgContext.setUseSOAPAction(true);
}
if (SOAPActionURI != null) {
msgContext.setSOAPActionURI(SOAPActionURI);
}
if (timeout != null) {
msgContext.setTimeout(timeout.intValue());
}
// Determine client target service
if (myService != null) {
// If we have a SOAPService kicking around, use that directly
msgContext.setService(myService);
} else {
if (portName != null) {
// No explicit service. If we have a target service name,
// try that.
msgContext.setTargetService(portName.getLocalPart());
} else {
// No direct config, so try the namespace of the first body.
reqMsg = msgContext.getRequestMessage();
if (reqMsg != null) {
reqEnv = reqMsg.getSOAPEnvelope();
SOAPBodyElement body = reqEnv.getFirstBody();
// Does this make any sense to anyone? If not, we should remove it.
// --Glen 03/16/02
//if ( body.getPrefix() == null ) body.setPrefix( "m" );
if ( body.getNamespaceURI() == null ) {
throw new AxisFault("Call.invoke",
Messages.getMessage("cantInvoke00", body.getName()),
null, null);
} else {
msgContext.setTargetService(body.getNamespaceURI());
}
}
}
SOAPService svc = msgContext.getService();
if (svc != null) {
svc.setPropertyParent(myProperties);
} else {
msgContext.setPropertyParent(myProperties);
}
}
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage("targetService",
msgContext.getTargetService()));
}
Message requestMessage = msgContext.getRequestMessage();
if (requestMessage != null) {
reqEnv = requestMessage.getSOAPEnvelope();
// If we have headers to insert, do so now.
for (int i = 0 ; myHeaders != null && i < myHeaders.size() ; i++ ) {
reqEnv.addHeader((SOAPHeaderElement)myHeaders.get(i));
}
}
// set up transport if there is one
if (transport != null) {
transport.setupMessageContext(msgContext, this, service.getEngine());
}
else
msgContext.setTransportName( transportName );
// For debugging - print request message
if (log.isDebugEnabled()) {
StringWriter writer = new StringWriter();
try {
SerializationContext ctx = new SerializationContextImpl(writer,
msgContext);
reqEnv.output(ctx);
writer.close();
} catch (Exception e) {
log.debug(Messages.getMessage("exceptionPrinting"), e);
} finally {
log.debug(writer.getBuffer().toString());