Search in sources :

Example 1 with MessageContext

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);
}
Also used : AxisFault(org.apache.axis.AxisFault) SOAPHeaderElement(org.apache.axis.message.SOAPHeaderElement) MessageContext(org.apache.axis.MessageContext) SOAPEnvelope(org.apache.axis.message.SOAPEnvelope)

Example 2 with MessageContext

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);
}
Also used : AxisFault(org.apache.axis.AxisFault) SOAPHeaderElement(org.apache.axis.message.SOAPHeaderElement) MessageContext(org.apache.axis.MessageContext) SOAPEnvelope(org.apache.axis.message.SOAPEnvelope)

Example 3 with MessageContext

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);
}
Also used : MessageContext(org.apache.axis.MessageContext) SOAPEnvelope(org.apache.axis.message.SOAPEnvelope)

Example 4 with MessageContext

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);
    }
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) UDF(lucee.runtime.type.UDF) TypeMapping(javax.xml.rpc.encoding.TypeMapping) PageContext(lucee.runtime.PageContext) MessageContext(org.apache.axis.MessageContext) Component(lucee.runtime.Component) FunctionArgument(lucee.runtime.type.FunctionArgument) Key(lucee.runtime.type.Collection.Key)

Example 5 with MessageContext

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;
}
Also used : QSWSDLHandler(org.apache.axis.transport.http.QSWSDLHandler) Iterator(java.util.Iterator) MessageContext(org.apache.axis.MessageContext) Method(java.lang.reflect.Method) AxisEngine(org.apache.axis.AxisEngine)

Aggregations

MessageContext (org.apache.axis.MessageContext)10 SOAPEnvelope (org.apache.axis.message.SOAPEnvelope)6 AxisFault (org.apache.axis.AxisFault)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Iterator (java.util.Iterator)3 Message (org.apache.axis.Message)3 SOAPHeaderElement (org.apache.axis.message.SOAPHeaderElement)3 MimeHeader (javax.xml.soap.MimeHeader)2 MimeHeaders (javax.xml.soap.MimeHeaders)2 SOAPMessage (javax.xml.soap.SOAPMessage)2 AxisEngine (org.apache.axis.AxisEngine)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Enumeration (java.util.Enumeration)1 ServletException (javax.servlet.ServletException)1 TypeMapping (javax.xml.rpc.encoding.TypeMapping)1 SOAPException (javax.xml.soap.SOAPException)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1