Package javax.ws.rs.client

Examples of javax.ws.rs.client.Client


                MultiPartMediaTypes.createMixed()));
    }

    @Test
    public void testChunkedEncodingUsingMultiPart() {
        final Client client = client();
        client.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        for (int i = 0; i < 900 * 1024; i++)
            baos.write(65);

        MultiPart multiPartInput = new MultiPart().
                bodyPart(new ByteArrayInputStream("01234567890123456789012345678901234567890123456789".getBytes()), MediaType.APPLICATION_OCTET_STREAM_TYPE).
                bodyPart(baos.toByteArray(), MediaType.APPLICATION_OCTET_STREAM_TYPE);

        client.target(getBaseUri()).path("resource").request().
                post(Entity.entity(multiPartInput, MultiPartMediaTypes.createMixed()));
    }
View Full Code Here


    public Response delete() throws Exception {
        return wrapResponse(METHOD_DELETE, getInvocationBuilder().delete());
    }

    private Builder getInvocationBuilder() throws Exception {
        Client client = customizeClient(ClientBuilder.newClient());
        client.register(HttpAuthenticationFeature.basic(getUserName(), getPassword()));
        WebTarget target = client.target(getUrl());
        for (Map.Entry<String, String> e : getQueryParams().entrySet()) {
            target = target.queryParam(e.getKey(), e.getValue());
        }
        return target.request(getResponseBodyMediaType()).header("X-Include-Resource-Links", "true").header("X-Requested-By", "MyClient");
    }
View Full Code Here

      final SSLContextFactory sslContextFactory,
      final ObjectMapperFactory objectMapperFactory,
      final ClientTransactionIdStrategy clientTransactionIdStrategy,
      final TransactionLogHandler transactionLogHandler) throws Exception {
    final ObjectMapper mapper = objectMapperFactory.createInstance();
    final Client client = createRESTClient(config, mapper,
        sslContextFactory);

    final WebTarget baseWebTarget = client.target(config.getBaseUri());
    final BlockingCommandExecutor blockingCommandExecutor = createBlockingCommandExecutor(
        clientTransactionIdStrategy, transactionLogHandler,
        baseWebTarget);

    return new DNSAPIClient(client, blockingCommandExecutor);
View Full Code Here

public class RestHelper {

  final Logger logger = LoggerFactory.getLogger(RestHelper.class);

  protected Client getClient() {
    Client client = ClientBuilder.newClient();
    client.register(JacksonFeature.class);
    return client;
  }
View Full Code Here

    client.register(JacksonFeature.class);
    return client;
  }

  protected Client getMultipartClient() {
    Client client = ClientBuilder.newClient();
    client.register(MultiPartFeature.class);
    return client;
  }
View Full Code Here

    client.register(MultiPartFeature.class);
    return client;
  }

  public Invocation.Builder createRequest(String url) {
    Client client = getClient();
    WebTarget target = client.target(url);
    return target.request();
  }
View Full Code Here

    WebTarget target = client.target(url);
    return target.request();
  }

  public Invocation.Builder createMultipartRequest(String url) {
    Client client = getMultipartClient();
    WebTarget target = client.target(url);
    return target.request();
  }
View Full Code Here

    public static void main(String[] args) {
        Message message = new Message();
        message.setText("Test message " + System.currentTimeMillis());

        Client client = ClientBuilder.newClient();
        client.register(JacksonJaxbJsonProvider.class);

        // set basic auth filter
        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("foo", "bar");
        client.register(feature);

        UriBuilder uri = UriBuilder.fromUri(BASE_URI);
        WebTarget target = client.target(uri.path("message").build());

        System.out.println("Creating message");
        Response r = target.request(MediaType.APPLICATION_JSON).post(Entity.entity(message, MediaType.APPLICATION_JSON));
        String location = (String) r.getHeaders().get("location").get(0);

        target = client.target(location);

        Message response = target.request(MediaType.APPLICATION_JSON).get(Message.class);

        WebTarget messagesResource = client.target(BASE_URI);
        MessageList messages = messagesResource.request(MediaType.APPLICATION_JSON).get(MessageList.class);
        for (Message entry : messages.getMessages()) {
            System.out.println("The message text for id " + entry.getId() + " is: " + entry.getText());
        }
View Full Code Here

public class GatewayClient {
    private static final int RECORDS = 1000;
    private static final String BASE_URL = "http://localhost:8181";

    public static void main(String[] args) throws Exception {
        Client client = ClientBuilder.newClient();
        URI uploadUri = UriBuilder.fromUri(BASE_URL).path("streaming").path("upload").build();

        WebTarget resource = client.target(uploadUri);
        Response response = resource.request().post(Entity.entity(generate(), MediaType.APPLICATION_OCTET_STREAM_TYPE));

        if (response.getStatus() == 204) {
            System.out.println("Upload completed");
        } else {
View Full Code Here

                    strings.get("internal", e.getMessage()), e);
        }
    }

    private static Client createClient() {
        Client c = JerseyClientBuilder.newClient();
        c.register(new MultiPartFeature())
            .register(new CsrfProtectionFilter("CLI"))
            .register(new ActionReportJsonReader())
            .register(new ParameterMapFormWriter())
            .register(new PayloadPartProvider())
            .register(new AdminCommandStateJsonReader())
View Full Code Here

TOP

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

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.