Package javax.ws.rs.client

Examples of javax.ws.rs.client.Client.target()


        builder.hostnameVerifier(CertificateHostnameVerifier.ALLOW_ALL);
       
       
        Client client = builder.build();
       
        WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123");
        Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class);
        assertEquals(123, b.getId());
    }
   
    private KeyStore loadStore(String trustStoreFile, String password) throws Exception {
View Full Code Here


        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Client c = createClient();
                    c.target("http://localhost:4848");
                } catch (Throwable th) {
                }
                try {
                    createStandardSslContext(System.console() != null);
                } catch (Throwable th) {
View Full Code Here

        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

    }

    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 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

    return client;
  }

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

  public Invocation.Builder createMultipartRequest(String url) {
    Client client = getMultipartClient();
View Full Code Here

    return target.request();
  }

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

        // 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);
View Full Code Here

        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);
View Full Code Here

        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

TOP
Copyright © 2018 www.massapi.com. 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.