String httpHeaders = (String)map.get("httpHeaders");
SAXEventBuffer headerContent = (SAXEventBuffer)map.get("header");
SAXEventBuffer bodyContent = (SAXEventBuffer)map.get("body");
SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = factory.createConnection();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
MimeHeaders mimeHeaders = message.getMimeHeaders();
SOAPEnvelope env = message.getSOAPPart().getEnvelope();
// Add headers, if any
if (httpHeaders != null) {
for (StringTokenizer st
= new StringTokenizer(httpHeaders, "\n");
st.hasMoreElements();) {
String hdr = st.nextToken();
int sep = hdr.indexOf(':');
if (sep < 0) {
throw new CannotExecuteException
("Invalid header (missing ':'): " + hdr);
}
mimeHeaders.addHeader
(hdr.substring(0, sep),
hdr.substring(sep + 1).trim());
}
}
// Add header content, if any
if (headerContent != null) {
SOAPHeader hdr = env.getHeader();
appendNodes (env, hdr, headerContent);
}
// Add body content
SOAPBody body = env.getBody();
appendNodes (env, body, bodyContent);
// Now invoke with the created message
SOAPMessage response = null;
try {
response = connection.call(message, new URL(endpoint));
} catch (SOAPException e) {
if (e.getMessage().indexOf("ConnectException") >= 0) {
// Axis way of reporting this
if (logger.isDebugEnabled()) {
logger.debug
("Cannot invoke (signalled ConnectException): "
+ e.getMessage (), e);
}
throw new CannotExecuteException
("Assuming connection failure: " + e.getMessage(),
new ConnectException (e.getMessage(), e));
} else if (e.getCause() != null
&& e.getCause().getCause() != null
&& (e.getCause().getCause()
instanceof java.net.ConnectException)) {
// JBossWS way of reporting this
throw new CannotExecuteException
("Assuming connection failure: " + e.getMessage(),
new ConnectException (e.getMessage(), e));
}
throw e;
} finally {
connection.close ();
}
SOAPPart respPart = response.getSOAPPart ();
Map resData = new HashMap ();
for (int i = 0; i < formPars.length; i++) {