Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.Client


    private com.sun.jersey.api.client.WebResource getUserWFRegistryBaseResource() {
        ClientConfig config = new DefaultClientConfig();
        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
                Boolean.TRUE);
        Client client = Client.create(config);
        WebResource baseWebResource = client.resource(getBaseURI());
        webResource = baseWebResource.path(
                ResourcePathConstants.UserWFConstants.REGISTRY_API_USERWFREGISTRY);
        return webResource;
    }
View Full Code Here


    private WebResource getDescriptorRegistryBaseResource() {
        ClientConfig config = new DefaultClientConfig();
        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
                Boolean.TRUE);
        Client client = Client.create(config);
        WebResource baseWebResource = client.resource(getBaseURI());
        webResource = baseWebResource.path(
                ResourcePathConstants.DecResourcePathConstants.DESC_RESOURCE_PATH);
        return webResource;
    }
View Full Code Here

    private WebResource getDescriptorRegistryBaseResource() {
        ClientConfig config = new DefaultClientConfig();
        config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
                Boolean.TRUE);
        Client client = Client.create(config);
        WebResource baseWebResource = client.resource(getBaseURI());
        webResource = baseWebResource.path(
                ResourcePathConstants.DecResourcePathConstants.DESC_RESOURCE_PATH);
        return webResource;
    }
View Full Code Here

    LocalServiceRegistry serviceRegistry = injector.getInstance(LocalServiceRegistry.class);
    httpServer = serviceRegistry.getAuxiliarySockets().get("http");
  }

  private ClientResponse get(String path) {
    Client client = Client.create();
    // Disable redirects so we can unit test them.
    client.setFollowRedirects(false);
    WebResource resource = client.resource(
        String.format("http://%s:%d%s", httpServer.getHostName(), httpServer.getPort(), path));
    return resource.getRequestBuilder()
        .header(HttpHeaders.ACCEPT_ENCODING, "gzip")
        .get(ClientResponse.class);
  }
View Full Code Here

        form.add("buildingName", "大成大樓888");
        ClientResponse response = r.type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class, form);
        System.out.println(response.getEntity(String.class));
       */

        Client c = Client.create();

        WebResource r = c.resource("http://portal.vivicloud.net/index.php/api/login_info");

        System.out.println("===== portal & trend integration =====");
        Form form = new Form();
        form.add("cookie", "myId");
        form.add("service", "大成大樓888");
View Full Code Here

import com.sun.jersey.api.representation.Form;

public class ContactClient {
 
  public static void main(String[] args) {
    Client c = Client.create();
    WebResource r = c.resource("http://localhost:8080/Jersey/rest/contacts");
   
    System.out.println("===== Get huangyim =====");
    getOneContact(r, "huangyim");
   
    System.out.println("===== Create foo =====");
View Full Code Here

        // retrieve consumer key/secret and token/secret from the property file
        // or system properties
        loadSettings();

        // create a new Jersey client
        Client client = Client.create();

        // create a new auth handler
        OAuthClientFilter.AuthHandler authHandler = new OAuthClientFilter.AuthHandler() {
            @Override
            public void authorized(String token, String tokenSecret) {
                // we received an authorized access token - store it for future runs
                PROPERTIES.setProperty(PROPERTY_TOKEN, token);
                PROPERTIES.setProperty(PROPERTY_TOKEN_SECRET, tokenSecret);
            }

            @Override
            public String authorize(URI authorizationUri) {
                try {
                    // we don't have an authorized access token
                    // ask user to provide authorization and return the generated
                    // verifier code
                    System.out.println("Enter the following URI into a web browser and authorize me:");
                    System.out.println(authorizationUri);
                    System.out.print("Enter the authorization code: ");
                    return IN.readLine();
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
        };

        // create a new OAuth client filter passing the needed info as well as the AuthHandler
        OAuthClientFilter filter = new OAuthClientFilter(
                client.getProviders(),
                new OAuthParameters().consumerKey(PROPERTIES.getProperty(PROPERTY_CONSUMER_KEY))
                    .token(PROPERTIES.getProperty(PROPERTY_TOKEN)),
                new OAuthSecrets().consumerSecret(PROPERTIES.getProperty(PROPERTY_CONSUMER_SECRET))
                    .tokenSecret(PROPERTIES.getProperty(PROPERTY_TOKEN_SECRET)),
                "http://twitter.com/oauth/request_token",
                "http://twitter.com/oauth/access_token",
                "http://twitter.com/oauth/authorize",
                authHandler);

        // Add filter to the client
        client.addFilter(filter);

        // make requests to protected resources
        // (no need to care about the authorization flow)
        do {
            List<Status> statuses = client.resource(FRIENDS_TIMELINE_URI)
                    .get(new GenericType<List<Status>>() {});
            for (Status s : statuses) {
                System.out.println(s.getText());
                System.out.println("[posted by " + s.getUser().getName() + " at " + s.getCreatedAt() + "]");
            }
View Full Code Here

        connection.disconnect();
    }

    @Test
    public void testCustomerResourceJersey() throws Exception {
        Client c = new Client();
        WebResource wr = c.resource("http://localhost:" + getJettyPort() + "/customers");

        System.out.println("*** Create a new Customer ***");
        Customer cust = new Customer();
        cust.setFirstName("Bill");
        cust.setLastName("Burke");
View Full Code Here

        connection.disconnect();
    }

    @Test
    public void testCustomerResourceJersey() throws Exception {
        Client c = new Client();
        WebResource wr = c.resource("http://localhost:" + getJettyPort() + "/customers/1");

        // Show the update
        System.out.println("**** Get Unknown Customer ***");
        ClientResponse response = wr.get(ClientResponse.class);

View Full Code Here

    }


    @Test
    public void testCustomerResourceJersey() throws Exception {
        Client c = new Client();
        WebResource wr = c.resource("http://localhost:" + getJettyPort() + "/customers");

        System.out.println("*** Create a new Customer ***");
        // Create a new customer
        String newCustomer = "<customer>"
                + "<first-name>Pavel</first-name>"
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.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.