Package javax.ws.rs.client

Examples of javax.ws.rs.client.Invocation


    WebTarget target = client.target(this.model);

    InputStream is = new FileInputStream(this.file);

    try {
      Invocation invocation = target.request(MediaType.APPLICATION_JSON_TYPE).buildPut(Entity.xml(is));

      String result = invocation.invoke(String.class);

      System.out.println(result);
    } finally {
      is.close();
    }
View Full Code Here


    WebTarget target = client.target(this.model);

    EvaluationRequest request = new EvaluationRequest();
    request.setArguments(this.arguments);

    Invocation invocation = target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(request));

    EvaluationResponse response = invocation.invoke(EvaluationResponse.class);

    System.out.println(response.getResult());

    client.close();
  }
View Full Code Here

    try {
      OutputStream os = new FileOutputStream(this.output);

      try {
        Invocation invocation = target.request(MediaType.TEXT_PLAIN).buildPost(Entity.text(is));

        InputStream result = invocation.invoke(InputStream.class);

        try {
          copy(result, os);
        } finally {
          result.close();
View Full Code Here

  public void run(){
    Client client = ClientBuilder.newClient();

    WebTarget target = client.target(this.model);

    Invocation invocation = target.request(MediaType.TEXT_PLAIN_TYPE).buildDelete();

    String result = invocation.invoke(String.class);

    System.out.println(result);

    client.close();
  }
View Full Code Here

                + request.getContextPath()
                + "/webresources/resource");

        // GET
        out.print("Building a GET request ...<br>");
        Invocation i1 = target.request().buildGet();
        out.print("GET request ready ...<br>");
       
        // POST
        out.print("Building a POST request...<br>");
        MultivaluedHashMap<String, String> map = new MultivaluedHashMap<>();
        map.add("name", "Name");
        map.add("age", "17");
        Invocation i2 = target.request().buildPost(Entity.form(map));
        out.print("POSTed request ready...<br>");
       
        Collection<Invocation> is = Arrays.asList(i1, i2);
       
        for (Invocation i : is) {
View Full Code Here

                request = addAdditionalHeaders(request);
                if (logger.isLoggable(Level.FINER)) {
                    request = request.header("X-Indent", "true");
                }
                //Make invocation
                Invocation invoc = null;
                Metrix.event("doRestCommand() - about to prepare invocation");
                if ("POST".equals(method)) {
                    if (outboundPayload != null && outboundPayload.size() > 0) {
                        FormDataMultiPart mp = new FormDataMultiPart();
                        //Copy params there
                        for (Map.Entry<String, List<String>> entry : options.entrySet()) {
                            String key = entry.getKey();
                            for (String val : entry.getValue()) {
                                mp.field(key, val);
                            }
                        }
                        //Copy outbound there
                        outboundPayload.addToMultipart(mp, logger);
                        Entity<FormDataMultiPart> entity = Entity.<FormDataMultiPart>entity(mp, mp.getMediaType());
                        invoc = request.build(method, entity);
                    } else {
                        Entity<ParameterMap> entity = Entity.<ParameterMap>entity(options, MediaType.APPLICATION_FORM_URLENCODED_TYPE);
                        invoc = request.build(method, entity);
                    }
                } else {
                    invoc = request.build(method);
                }
                //todo: set timeout
//                urlConnection.setReadTimeout(readTimeout);
//                if (connectTimeout >= 0)
//                    urlConnection.setConnectTimeout(connectTimeout);

                //Invoke
                Metrix.event("doRestCommand() - about to invoke");
                Response response;
                try {
                    response = invoc.invoke();
                } catch (ClientException ex) {
                    //Rethrow original execaption (not Throwable) for future processing
                    if (ex.getCause() != null && ex.getCause() instanceof Exception) {
                        throw (Exception) ex.getCause();
                    } else {
View Full Code Here

TOP

Related Classes of javax.ws.rs.client.Invocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.