} else {
try {
Binding type = Binding.valueOf(style.toUpperCase());
style = type.getBindingId();
} catch (IllegalArgumentException e) {
throw new TranslatorException(WSExecutionFactory.UTIL.getString("invalid_invocation", Arrays.toString(Binding.values()))); //$NON-NLS-1$
}
}
Dispatch<StreamSource> dispatch = conn.createDispatch(style, endpoint, StreamSource.class, executionFactory.getDefaultServiceMode());
if (Binding.HTTP.getBindingId().equals(style)) {
if (action == null) {
action = "POST"; //$NON-NLS-1$
}
dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, action);
if (source != null && !"POST".equalsIgnoreCase(action)) { //$NON-NLS-1$
if (this.executionFactory.getXMLParamName() == null) {
throw new WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error")); //$NON-NLS-1$
}
try {
Transformer t = TransformerFactory.newInstance().newTransformer();
StringWriter writer = new StringWriter();
//TODO: prevent this from being too large
t.transform(source, new StreamResult(writer));
String param = Util.httpURLEncode(this.executionFactory.getXMLParamName())+"="+Util.httpURLEncode(writer.toString()); //$NON-NLS-1$
endpoint = WSConnection.Util.appendQueryString(endpoint, param);
} catch (TransformerException e) {
throw new WebServiceException(e);
}
}
} else {
if (action != null) {
dispatch.getRequestContext().put(Dispatch.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
dispatch.getRequestContext().put(Dispatch.SOAPACTION_URI_PROPERTY, action);
}
}
if (source == null) {
// JBoss Native DispatchImpl throws exception when the source is null
source = new StreamSource(new StringReader("<none/>")); //$NON-NLS-1$
}
this.returnValue = dispatch.invoke(source);
} catch (SQLException e) {
throw new TranslatorException(e);
} catch (WebServiceException e) {
throw new TranslatorException(e);
} finally {
Util.closeSource(source);
}
}