Invocation point: Method called by TECore for request or soap-request.

{@code <parsers:HTTPParser /> }
355021
public static Document parse(URLConnection uc, Element instruction,
            PrintWriter logger, TECore core) throws Throwable {
		try {
			uc.connect();
		} catch (SSLProtocolException sslep) {
			throw new SSLProtocolException("[SSL ERROR] Failed to connect with the requested URL due to \"Invalid server_name\" found!! :" + uc.getURL() +":" + sslep.getClass() +" : "+ sslep.getMessage());
		}
        String mime = uc.getContentType();
        boolean multipart = (mime != null && mime.startsWith("multipart"));

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        // Fortify Mod: prevent external entity injection
        dbf.setExpandEntityReferences(false);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.newDocument();
        Element root = doc.createElement(multipart ? "multipart-response"
                : "response");
        if (uc.getHeaderFieldKey(0) == null) {
            Element status = doc.createElement("status");
            String status_line = uc.getHeaderField(0);
            if (status_line != null) {
                String[] status_array = status_line.split("\\s");
                if (status_array.length > 0) {
                    status.setAttribute("protocol", status_array[0]);
                }
                if (status_array.length > 1) {
                    status.setAttribute("code", status_array[1]);
                }
                if (status_array.length > 2) {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 2; i < status_array.length; i++) {
                        sb.append(status_array[i]);
                        sb.append(" ");
                    }
                    status.appendChild(doc.createTextNode(sb.toString().trim()));
                }
            }
            root.appendChild(status);
        }

        append_headers(uc, root);
        // Fortify Mod: prevent external entity injection 
        TransformerFactory tf = TransformerFactory.newInstance();
        tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        Transformer t = tf.newTransformer();
        // Transformer t = TransformerFactory.newInstance().newTransformer();

        if (multipart) {
            String mime2 = mime + ";";
            int start = mime2.indexOf("boundary=") + 9;
            char endchar = ';';
            if (mime2.charAt(start) == '"') {
                start++;
                endchar = '"';
            }
            int end = mime2.indexOf(endchar, start);
            String boundary = mime2.substring(start, end);
            InputStream is = URLConnectionUtils.getInputStream(uc);
            BufferedReader in = new BufferedReader(new InputStreamReader(is));
            File temp = create_part_file(in, boundary);
            temp.delete();
            String line = in.readLine();
            int num = 1;
            while (!line.endsWith("--")) {
                String contentType = "text/plain";
                Element part = doc.createElement("part");
                part.setAttribute("num", Integer.toString(num));
                Element headers = doc.createElement("headers");
                line = in.readLine();
                while (line.length() > 0) {
                    Element header = doc.createElement("header");
                    int colon = line.indexOf(":");
                    String name = line.substring(0, colon);
                    String value = line.substring(colon + 1).trim();
                    if (name.toLowerCase().equals("content-type")) {
                        contentType = value;
                    }
                    header.setAttribute("name", name);
                    header.appendChild(doc.createTextNode(value));
                    headers.appendChild(header);
                    line = in.readLine();
                }
                part.appendChild(headers);
                temp = create_part_file(in, boundary);
                URLConnection pc = temp.toURI().toURL().openConnection();
                pc.setRequestProperty("Content-type", mime);
                Node parser = select_parser(num, contentType, instruction);
                // use TECore to invoke any subsidiary (chained) parsers
                Element response_e = core.parse(pc, parser);
                temp.delete();
                Element parser_e = (Element) (response_e
                        .getElementsByTagName("parser").item(0));
                if (parser_e != null) {
                    logger.print(parser_e.getTextContent());
                }
                Element content = (Element) (response_e
                        .getElementsByTagName("content").item(0));
                if ((null != content) && content.hasChildNodes()) {
                    t.transform(new DOMSource(content), new DOMResult(part));
                }
                root.appendChild(part);
                line = in.readLine();
                num++;
            }
            // Fortify Mod: Close the BufferedReader and release its resources
            in.close();
        } else {
            Node parser = select_parser(0, uc.getContentType(), instruction);
            // use TECore to invoke any chained (subsidiary) parsers
            if (LOGR.isLoggable(Level.FINER)) {
                String msg = String.format(
                        "Calling subsidiary parser for resource at %s:%n%s",
                        uc.getURL(), DomUtils.serializeNode(parser));
                LOGR.finer(msg);
            }
            Element response_e = core.parse(uc, parser);
            Element parser_e = (Element) (response_e
                    .getElementsByTagName("parser").item(0));
            if (parser_e != null) {
                logger.print(parser_e.getTextContent());
            }
            Element content = (Element) (response_e
                    .getElementsByTagName("content").item(0));
            if (null != content) {
                root.appendChild(doc.importNode(content, true));
            }
        }
        doc.appendChild(root);
        return doc;
    }
442272
@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		if (DISABLED || !SERVICES_COUNTER.isDisplayed()) {
			return method.invoke(facade, args);
		}
		// nom identifiant la requête
		final String requestName = getRequestName(method);

		return invokeTarget(facade, method, args, requestName);
	}
522052
void doMethod(HttpServletRequest request, HttpServletResponse response, HttpMethod httpMethod) {

        // Locate a request handler:
        String requestPath = mapRequestPath(request);
        Route route = api.get(requestPath);

        try {

            if (route != null && route.requestHandlers.containsKey(httpMethod)) {
                handleRequest(request, response, route, httpMethod);
            } else {
                handleNotFound(request, response);
            }

        } catch (Throwable t) {

            // Chances are the exception we've actually caught is the reflection
            // one from Method.invoke(...)
            Throwable caught = t;
            if (InvocationTargetException.class.isAssignableFrom(t.getClass())) {
                caught = t.getCause();
            }

            RequestHandler requestHandler = (route == null ? null : route.requestHandlers.get(httpMethod));
            handleError(request, response, requestHandler, caught);
        }

    }
90363
public void call(final T request, final Functor<String, RemoteService.Response> process) {
        call(request, process, null);
    }
859523
@Override
	public ISynchronizationPoint<Exception> start() {
		SynchronizationPoint<Exception> sp = new SynchronizationPoint<>();
		io.canStartReading().listenAsync(new Task.Cpu.FromRunnable(() -> {
			try {
				Starter start = new Starter(io, defaultEncoding, charactersBuffersSize, maxBuffers);
				stream = start.start();
				next().listenInline(sp);
			} catch (Exception e) {
				sp.error(e);
			}
		}, "Start parsing XML", io.getPriority()), true);
		return sp;
	}
477398
<R extends Request<T>> R setRequestQueue(RequestQueue requestQueue) {
        checkIfActive();
        java.lang.reflect.Method m = null;
        if (!(this.getClass().equals(Request.class))) {
            try {
                m = this.getClass().getDeclaredMethod("parseNetworkResponse", NetworkResponse
                        .class);
            } catch (NoSuchMethodException e) {
                //e.printStackTrace();
            }
        }
        if (converterFromResponse == null) {
            Type t;
            if (responseType != null) {
                t = responseType;
            } else {
                t = tryIdentifyResultType(this);
            }
            if (t == null) {
                throw new IllegalArgumentException("Cannot resolve Response type in order to " +
                        "identify Response Converter for Request : " + this);
            }

            try {
                this.converterFromResponse =
                        (Converter<NetworkResponse, T>) requestQueue
                                .getResponseConverter(t, new Annotation[0]);
            } catch (IllegalArgumentException ex) {
                //check if parseNetworkResponse is overridden
                if (m == null) {
                    //it is not so it is for sure that we cannot parse response thus throw
                    throw ex;
                }
                //else keep quiet as conversion can probably be handled by the overridden method.
                // if it fails parse exception will be thrown.
            }


        }
        if (retryPolicy == null) {
            setRetryPolicy(new DefaultRetryPolicy(this));
        }
        this.requestQueue = requestQueue;
        return (R) this;
    }
155642
protected RequestParser<T> createRequestParser()
    {
        //get parser configuration
        String configurationKey=this.getRequestParserConfigurationKey();
        String defaultParserClassName=this.getDefaultParserClassName();
        
        //create parser
        RequestParser<T> parser=this.createRequestParser(configurationKey,defaultParserClassName);
        
        return parser;
    }
451951
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
        try {
            logRequest("Sending SOAP request", messageContext, false);
        } catch (SoapEnvelopeException e) {
            log.warn("Unable to write SOAP request to logger", e);
        } catch (TransformerException e) {
            log.warn("Unable to write SOAP request to logger", e);
        }
        
        return true;
    }
371075
public boolean invokeEndpoint(final MessageEndpoint endpoint,
            final SIBusMessage message, final AbstractConsumerSession session,
            final SITransaction transaction, String debugMEName)
            throws ResourceAdapterInternalException {

        final String methodName = "invokeEndpoint";
        if (TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, new Object[] { endpoint,
                    message, session, transaction });
        }

        // Check that endpoint is a SibRaMessageListener
        if (!(endpoint instanceof SibRaMessageListener)) {

            throw new ResourceAdapterInternalException(NLS.getFormattedMessage(
                    ("UNEXPECTED_ENDPOINT_CWSIV0850"), new Object[] { endpoint,
                            SibRaMessageListener.class }, null));

        }

        final SibRaMessageListener listener = (SibRaMessageListener) endpoint;

        // Wrap session before passing to MDB
        final SibRaAbstractConsumerSession wrappedSession = new SibRaAbstractConsumerSession(
                session);

        boolean success;
        try {

            // Deliver message
            listener.onMessage(message, wrappedSession, transaction);
            success = true;

        } catch (final Throwable exc) {

            // Failed to deliver message
            FFDCFilter.processException(exc, CLASS_NAME + "." + methodName,
                    FFDC_PROBE_1, this);
            if (TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exc);
            }
            success = false;
            // If the throwable is a ThreadDeath then we want to rethrow the
            // exception to make sure that the thread dies correctly
            if (exc instanceof ThreadDeath)
            {
              // we cast to a threaddeath so we don't have to declare the throwable
              throw (ThreadDeath)exc;
            }

        } finally {

            // Stop an MDB that has cached the session reusing it
            wrappedSession.outOfScope();

        }

        if (TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName, Boolean.valueOf(success));
        }
        return success;

    }
1362638
public static Object[] call(Method method, Object[][] params,
                              InetSocketAddress[] addrs,
                              UserGroupInformation ticket, Configuration conf)
    throws IOException {

    Invocation[] invocations = new Invocation[params.length];
    for (int i = 0; i < params.length; i++)
      invocations[i] = new Invocation(method, null, params[i]);
    Client client = CLIENTS.getClient(conf);
    try {
    Writable[] wrappedValues =
      client.call(invocations, addrs, method.getDeclaringClass(), ticket);

    if (method.getReturnType() == Void.TYPE) {
      return null;
    }

    Object[] values =
      (Object[])Array.newInstance(method.getReturnType(), wrappedValues.length);
    for (int i = 0; i < values.length; i++)
      if (wrappedValues[i] != null)
        values[i] = ((ObjectWritable)wrappedValues[i]).get();
    
    return values;
    } finally {
      CLIENTS.stopClient(client);
    }
  }
23741
@Trivial
    @Override
    public Object invoke(Object o, Method m, Object[] params) throws Throwable {

        Class<?> declaringClass = m.getDeclaringClass();
        if (Client.class == declaringClass || InvocationHandlerAware.class == declaringClass
            || Object.class == declaringClass) {
            return m.invoke(this, params);
        }
        resetResponse();
        OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(m);
        if (ori == null) {
            reportInvalidResourceMethod(m, "INVALID_RESOURCE_METHOD");
        }

        MultivaluedMap<ParameterType, Parameter> types = getParametersInfo(m, params, ori);
        List<Parameter> beanParamsList = getParameters(types, ParameterType.BEAN);

        int bodyIndex = getBodyIndex(types, ori);

        List<Object> pathParams = getPathParamValues(m, params, types, beanParamsList, ori, bodyIndex);

        UriBuilder builder = getCurrentBuilder().clone();
        if (isRoot) {
            addNonEmptyPath(builder, ori.getClassResourceInfo().getURITemplate().getValue());
        }
        addNonEmptyPath(builder, ori.getURITemplate().getValue());

        handleMatrixes(m, params, types, beanParamsList, builder);
        handleQueries(m, params, types, beanParamsList, builder);

        URI uri = builder.buildFromEncoded(pathParams.toArray()).normalize();

        MultivaluedMap<String, String> headers = getHeaders();
        MultivaluedMap<String, String> paramHeaders = new MetadataMap<String, String>();
        handleHeaders(m, params, paramHeaders, beanParamsList, types);
        handleCookies(m, params, paramHeaders, beanParamsList, types);

        if (ori.isSubResourceLocator()) {
            ClassResourceInfo subCri = cri.getSubResource(m.getReturnType(), m.getReturnType());
            if (subCri == null) {
                reportInvalidResourceMethod(m, "INVALID_SUBRESOURCE");
            }

            MultivaluedMap<String, String> subHeaders = paramHeaders;
            if (inheritHeaders) {
                subHeaders.putAll(headers);
            }

            ClientState newState = getState().newState(uri, subHeaders,
                                                       getTemplateParametersMap(ori.getURITemplate(), pathParams));
            ClientProxyImpl proxyImpl = new ClientProxyImpl(newState, proxyLoader, subCri, false, inheritHeaders);
            proxyImpl.setConfiguration(getConfiguration());
            return JAXRSClientFactory.createProxy(m.getReturnType(), proxyLoader, proxyImpl);
        }
        headers.putAll(paramHeaders);

        getState().setTemplates(getTemplateParametersMap(ori.getURITemplate(), pathParams));

        Object body = null;
        if (bodyIndex != -1) {
            body = params[bodyIndex];
            if (body == null) {
                bodyIndex = -1;
            }
        } else if (types.containsKey(ParameterType.FORM)) {
            body = handleForm(m, params, types, beanParamsList);
        } else if (types.containsKey(ParameterType.REQUEST_BODY)) {
            body = handleMultipart(types, ori, params);
        }

        setRequestHeaders(headers, ori, types.containsKey(ParameterType.FORM),
                          body == null ? null : body.getClass(), m.getReturnType());

        try {
            return doChainedInvocation(uri, headers, ori, params, body, bodyIndex, null, null);
        } finally {
            resetResponseStateImmediatelyIfNeeded();
        }

    }
332989
private Object invokeRpc(Method method, Object[] args) throws Exception {
		String methodName = method.getName();
		Class<?>[] parameterTypes = method.getParameterTypes();
		Annotation[][] parameterAnnotations = method.getParameterAnnotations();
		Time futureTimeout = extractRpcTimeout(parameterAnnotations, args, timeout);

		final RpcInvocation rpcInvocation = createRpcInvocationMessage(methodName, parameterTypes, args);

		Class<?> returnType = method.getReturnType();

		final Object result;

		if (Objects.equals(returnType, Void.TYPE)) {
			tell(rpcInvocation);

			result = null;
		} else {
			// execute an asynchronous call
			CompletableFuture<?> resultFuture = ask(rpcInvocation, futureTimeout);

			CompletableFuture<?> completableFuture = resultFuture.thenApply((Object o) -> {
				if (o instanceof SerializedValue) {
					try {
						return  ((SerializedValue<?>) o).deserializeValue(getClass().getClassLoader());
					} catch (IOException | ClassNotFoundException e) {
						throw new CompletionException(
							new RpcException("Could not deserialize the serialized payload of RPC method : "
								+ methodName, e));
					}
				} else {
					return o;
				}
			});

			if (Objects.equals(returnType, CompletableFuture.class)) {
				result = completableFuture;
			} else {
				try {
					result = completableFuture.get(futureTimeout.getSize(), futureTimeout.getUnit());
				} catch (ExecutionException ee) {
					throw new RpcException("Failure while obtaining synchronous RPC result.", ExceptionUtils.stripExecutionException(ee));
				}
			}
		}

		return result;
	}
1305096
private Object invoke(ServiceRequestContext ctx, HttpRequest req, @Nullable AggregatedHttpMessage message) {
        try (SafeCloseable ignored = ctx.push(false)) {
            final ResolverContext resolverContext = new ResolverContext(ctx, req, message);
            final Object[] arguments = toArguments(resolvers, resolverContext);
            return method.invoke(object, arguments);
        } catch (Throwable cause) {
            return exceptionHandler.handleException(ctx, req, cause);
        }
    }
1005131
public ApiResponse<GetArgsResponse> argsWithHttpInfo() throws ApiException {
        com.squareup.okhttp.Call call = argsValidateBeforeCall(null, null);
        Type localVarReturnType = new TypeToken<GetArgsResponse>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
1009498
@SuppressWarnings("unchecked")
    @Override
    protected T call() throws CoreException {

        this.wave.status(Status.Consumed);

        T res = null;
        try {

            // Build parameter list of the searched method
            final List<Object> params = new ArrayList<>();
            for (final Object o : this.parameterValues) {
                params.add(o);
            }
            // Add the current wave to process
            params.add(this.wave);

            // Call this method with right parameters
            res = (T) this.method.invoke(this.service, params.toArray());

            if (Void.TYPE.equals(this.method.getReturnType()) && this.wave.waveType().returnItem() != JRebirthItems.voidItem) {
                // No return wave required because the service method will return nothing (VOID)
                LOGGER.log(NO_RETURN_WAVE_CONSUMED, this.service.getClass().getSimpleName(), this.wave.toString());
                // Consumed + Handled because there is only one handler: the service task
                this.wave.status(Status.Handled);

                // Otherwise prepare the return wave
            } else {

                // Send the result into a wave
                sendReturnWave(res);

            }

        } catch (IllegalAccessException | IllegalArgumentException e) {
            handleException(e);
        } catch (final InvocationTargetException e) {
            if (e.getTargetException() != null) {
                handleException(e.getTargetException());
            } else {
                handleException(e);
            }
        } catch (final ServiceException se) {
            handleException(se.getCause());
        } catch (final Exception e) { // NOSONAR, catch all to try to do something smart !
            handleException(e);
        }
        return res;
    }
1357425
@Override
  protected boolean requestInvoke(FrameBuffer frameBuffer) {
    Runnable invocation = getRunnable(frameBuffer);
    if (invoker != null) {
      try {
        invoker.execute(invocation);
        return true;
      } catch (RejectedExecutionException rx) {
        LOGGER.warn("ExecutorService rejected execution!", rx);
        return false;
      }
    } else {
      // Invoke on the caller's thread
      invocation.run();
      return true;
    }
  }
822383
@Override
    public T call()
            throws Exception
    {
        T response = requestor.call();

        try {
            validateResponse( response );
            return response;

        } catch ( RuntimeException ex ) {
            if ( response instanceof Closeable ) {
                PcsUtils.closeQuietly( ( Closeable ) response );
            }
            throw ex;
        }
    }