= 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++) {
if (formPars[i].mode() == FormalParameter.Mode.IN) {
continue;
}
XPath path = (XPath)returnParamInfo.get(formPars[i].id());
if (path == null) {
resData.put(formPars[i].id(),
convertToSax(respPart.getDocumentElement()));
} else {
if (formPars[i].type().equals (String.class)) {
resData.put(formPars[i].id(),
path.stringValueOf(respPart));
} else if ((formPars[i].type() instanceof Class)
&& Number.class.isAssignableFrom
((Class)formPars[i].type())) {
Number n = path.numberValueOf(respPart);
if (formPars[i].type().equals (Long.class)
&& !(n instanceof Long)) {
n = new Long (n.longValue());
}
resData.put(formPars[i].id(), n);
} else {
resData.put(formPars[i].id(),
convertToSax(path.selectNodes(respPart)));
}
}
}
result.set (resData);
} catch (CannotExecuteException e) {
throw e;
} catch (MalformedURLException e) {
throw new CannotExecuteException (e.getMessage(), e);
} catch (SOAPException e) {
throw new CannotExecuteException (e.getMessage(), e);
} catch (SAXException e) {
throw new CannotExecuteException (e.getMessage(), e);
} catch (JaxenException e) {
throw new CannotExecuteException (e.getMessage(), e);
} catch (TransformerException e) {
throw new CannotExecuteException (e.getMessage(), e);
}
}