use of org.apache.axis.MessageContext in project Lucee by lucee.
the class AxisUtil method addSOAPResponseHeader.
public static void addSOAPResponseHeader(String namespace, String name, Object value, boolean mustUnderstand) throws AxisFault {
MessageContext context = MessageContext.getCurrentContext();
if (context == null || context.isClient())
throw new AxisFault("not inside a Soap Request");
SOAPEnvelope env = context.getResponseMessage().getSOAPEnvelope();
SOAPHeaderElement header = toSOAPHeaderElement(namespace, name, value);
header.setMustUnderstand(mustUnderstand);
env.addHeader(header);
}
use of org.apache.axis.MessageContext in project Lucee by lucee.
the class AxisUtil method getSOAPRequestHeader.
public static Object getSOAPRequestHeader(PageContext pc, String namespace, String name, boolean asXML) throws Exception {
MessageContext context = MessageContext.getCurrentContext();
if (context == null || context.isClient())
throw new AxisFault("not inside a Soap Request");
SOAPEnvelope env = context.getRequestMessage().getSOAPEnvelope();
SOAPHeaderElement header = env.getHeaderByName(namespace, name);
return toValue(header, asXML);
}
use of org.apache.axis.MessageContext in project Lucee by lucee.
the class AxisUtil method getSOAPRequest.
public static Node getSOAPRequest(WSClient client) throws Exception {
MessageContext context = getMessageContext(client);
SOAPEnvelope env = context.getRequestMessage().getSOAPEnvelope();
return XMLCaster.toXMLStruct(env.getAsDocument(), true);
}
use of org.apache.axis.MessageContext in project Lucee by lucee.
the class ComponentController method _invoke.
public static Object _invoke(String name, Object[] args) throws PageException {
Key key = Caster.toKey(name);
Component c = component.get();
PageContext p = pagecontext.get();
MessageContext mc = messageContext.get();
if (c == null)
throw new ApplicationException("missing component");
if (p == null)
throw new ApplicationException("missing pagecontext");
UDF udf = Caster.toFunction(c.get(p, key, null), null);
FunctionArgument[] fa = null;
if (udf != null)
fa = udf.getFunctionArguments();
for (int i = 0; i < args.length; i++) {
if (fa != null && i < fa.length && fa[i].getType() == CFTypes.TYPE_UNKNOW) {
args[i] = AxisCaster.toLuceeType(p, fa[i].getTypeAsString(), args[i]);
} else
args[i] = AxisCaster.toLuceeType(p, args[i]);
}
// return type
String rtnType = udf != null ? udf.getReturnTypeAsString() : "any";
Object rtn = c.call(p, key, args);
// cast return value to Axis type
try {
RPCServer server = RPCServer.getInstance(p.getId(), p, p.getServletContext());
TypeMapping tm = mc != null ? mc.getTypeMapping() : TypeMappingUtil.getServerTypeMapping(server.getEngine().getTypeMappingRegistry());
rtn = Caster.castTo(p, rtnType, rtn, false);
Class<?> clazz = Caster.cfTypeToClass(rtnType);
return AxisCaster.toAxisType(tm, rtn, clazz.getComponentType() != null ? clazz : null);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
}
}
use of org.apache.axis.MessageContext in project Lucee by lucee.
the class RPCServer method doGet.
private boolean doGet(HttpServletRequest request, HttpServletResponse response, PrintWriter writer, Component component) throws AxisFault, ClassException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
String path = request.getServletPath();
String queryString = request.getQueryString();
AxisEngine engine = getEngine();
Iterator i = this.transport.getOptions().keySet().iterator();
if (queryString == null) {
return false;
}
String servletURI = request.getContextPath() + path;
String reqURI = request.getRequestURI();
// service name
String serviceName;
if (servletURI.length() + 1 < reqURI.length()) {
serviceName = reqURI.substring(servletURI.length() + 1);
} else {
serviceName = "";
}
while (i.hasNext()) {
String queryHandler = (String) i.next();
if (queryHandler.startsWith("qs.")) {
// Only attempt to match the query string with transport
// parameters prefixed with "qs:".
String handlerName = queryHandler.substring(queryHandler.indexOf(".") + 1).toLowerCase();
// Determine the name of the plugin to invoke by using all text
// in the query string up to the first occurence of &, =, or the
// whole string if neither is present.
int length = 0;
boolean firstParamFound = false;
while (firstParamFound == false && length < queryString.length()) {
char ch = queryString.charAt(length++);
if (ch == '&' || ch == '=') {
firstParamFound = true;
--length;
}
}
if (length < queryString.length()) {
queryString = queryString.substring(0, length);
}
if (queryString.toLowerCase().equals(handlerName) == true) {
if (this.transport.getOption(queryHandler).equals("")) {
return false;
}
// Attempt to dynamically load the query string handler
// and its "invoke" method.
MessageContext msgContext = createMessageContext(engine, request, response, component);
msgContext.setProperty(MessageContext.TRANS_URL, HttpUtils.getRequestURL(request).toString().toLowerCase());
// msgContext.setProperty(MessageContext.TRANS_URL, "http://DefaultNamespace");
msgContext.setProperty(HTTPConstants.PLUGIN_SERVICE_NAME, serviceName);
msgContext.setProperty(HTTPConstants.PLUGIN_NAME, handlerName);
msgContext.setProperty(HTTPConstants.PLUGIN_IS_DEVELOPMENT, Caster.toBoolean(isDevelopment));
msgContext.setProperty(HTTPConstants.PLUGIN_ENABLE_LIST, Boolean.FALSE);
msgContext.setProperty(HTTPConstants.PLUGIN_ENGINE, engine);
msgContext.setProperty(HTTPConstants.PLUGIN_WRITER, writer);
msgContext.setProperty(HTTPConstants.PLUGIN_LOG, toLog(log));
msgContext.setProperty(HTTPConstants.PLUGIN_EXCEPTION_LOG, toLog(exceptionLog));
String handlerClassName = (String) this.transport.getOption(queryHandler);
if ("org.apache.axis.transport.http.QSWSDLHandler".equals(handlerClassName)) {
QSWSDLHandler handler = new QSWSDLHandler();
handler.invoke(msgContext);
} else {
// Invoke the plugin.
Class plugin = ClassUtil.loadClass((String) this.transport.getOption(queryHandler));
Method pluginMethod = plugin.getDeclaredMethod("invoke", new Class[] { msgContext.getClass() });
pluginMethod.invoke(ClassUtil.loadInstance(plugin), new Object[] { msgContext });
}
writer.close();
return true;
}
}
}
return false;
}
Aggregations