当前位置: 首页>>代码示例>>Java>>正文


Java WebTarget.path方法代码示例

本文整理汇总了Java中javax.ws.rs.client.WebTarget.path方法的典型用法代码示例。如果您正苦于以下问题:Java WebTarget.path方法的具体用法?Java WebTarget.path怎么用?Java WebTarget.path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.client.WebTarget的用法示例。


在下文中一共展示了WebTarget.path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAbort

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testAbort() throws Exception {
	logger.info("Registering Client Abort Filters");
	Client client = newClient();
	client.register(new MyClientResponseFilter());
	client.register(new MyClientRequestFilter());
	client.register(new BlockChainFilter());
	WebTarget target = client.target(url + "myjaxrs/simple/");

	WebTarget resourceTarget = target.path("/valuesget");
	resourceTarget = resourceTarget.queryParam("OrderID", "111").queryParam("UserName", "Luke");

	logger.info("Invoking REST Service: " + resourceTarget.getUri().toString());
	Invocation invocation = resourceTarget.request().buildGet();
	Response response = invocation.invoke();

	assertEquals(
			"MyClientRequestFilter is not executed because BlockChainFilter blocks it. So no header is saved: ", "",
			response.getHeaderString(CONTENT_TYPE_STRING));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:22,代码来源:ComponentTestCase.java

示例2: testGet

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testGet() throws Exception {
	logger.info("Registering Client Level Filters");
	Client client = newClient();
	client.register(new OtherClientResponseFilter());
	WebTarget target = client.target(url + "myjaxrs/simple/");
	target.register(new OtherClientRequestFilter());

	WebTarget resourceTarget = target.path("/valuesget");
	resourceTarget = resourceTarget.queryParam("OrderID", "111").queryParam("UserName", "Luke");
	resourceTarget.register(new MyClientResponseFilter());
	resourceTarget.register(new MyClientRequestFilter());

	logger.info("Invoking REST Service: " + resourceTarget.getUri().toString());
	Invocation invocation = resourceTarget.request().buildGet();
	Response response = invocation.invoke();
	String respContent = "";

	if (response.hasEntity())
		respContent = response.readEntity(String.class);

	assertEquals("Response--> ", "111-Luke", respContent);
	assertEquals("Content Type after changing in ClientResponseFilter: ", TEXT_HTML,
			response.getHeaderString(CONTENT_TYPE_STRING));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:27,代码来源:ComponentTestCase.java

示例3: clearRemoteCacheREST

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
private String clearRemoteCacheREST(RESTClient<String> client, Class<?> entityClass) {
	WebTarget target = client.getService().path(client.getApplicationURI())
			.path(client.getEndpointURI());
	if (entityClass != null) {
		target = target.path("class").path(entityClass.getName());
	} else {
		target = target.path("cache");
	}
	Response response = target.request(MediaType.TEXT_PLAIN).delete();
	String message = null;
	if (response.getStatus() == 200) {
		message = response.readEntity(String.class);
	}
	response.close();
	return message;
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:17,代码来源:CacheManager.java

示例4: QuerryBillStatus

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
public String QuerryBillStatus(String merchant_trans_id, String good_code, String trans_id, String merchant_code, String secure_hash) throws ClientErrorException {
    WebTarget resource = webTarget;
    if (merchant_code != null) {
        resource = resource.queryParam("merchant_code", merchant_code);
    }
    if (good_code != null) {
        resource = resource.queryParam("good_code", good_code);
    }
    if (merchant_trans_id != null) {
        resource = resource.queryParam("merchant_trans_id", merchant_trans_id);
    }
    if (secure_hash != null) {
        resource = resource.queryParam("secure_hash", secure_hash);
    }
    if (trans_id != null) {
        resource = resource.queryParam("trans_id", trans_id);
    }
    resource = resource.path("QuerryBillStatus");
    return resource.request(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:21,代码来源:KPRest.java

示例5: QuerryBillStatus

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
public String QuerryBillStatus(String merchant_trans_id, String good_code, String trans_id, String merchant_code,
		String secure_hash) throws ClientErrorException {
	WebTarget resource = webTarget;
	if (merchant_code != null) {
		resource = resource.queryParam("merchant_code", merchant_code);
	}
	if (good_code != null) {
		resource = resource.queryParam("good_code", good_code);
	}
	if (merchant_trans_id != null) {
		resource = resource.queryParam("merchant_trans_id", merchant_trans_id);
	}
	if (secure_hash != null) {
		resource = resource.queryParam("secure_hash", secure_hash);
	}
	if (trans_id != null) {
		resource = resource.queryParam("trans_id", trans_id);
	}
	resource = resource.path("QuerryBillStatus");
	return resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(String.class);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:22,代码来源:KPJsonRest.java

示例6: generateClient

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
public <T> T generateClient(Class<T> resource) {
    Client clientToUse = client != null
            ? client
            : ClientBuilder.newClient();

    MultivaluedMap<String, Object> headerArg = new MultivaluedHashMap<>(headers);

    WebTarget webTarget = clientToUse.target(uri);
    if (apiPath != null) {
        webTarget = webTarget.path(apiPath);
    }
    if(throwExceptionForErrors) {
        webTarget.register(ClientErrorResponseFilter.class);
    }
    webTarget.register(RequestIdClientFilter.class);
    webTarget.register(ClientNameFilter.class);
    if (logging) {
        webTarget.register(ClientLogFilter.class);
    }

    return WebResourceFactory.newResource(resource, webTarget, false, headerArg, cookies, new Form());
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:23,代码来源:StubGenerator.java

示例7: initMasterClient

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
private static void initMasterClient() {
  JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
  ObjectMapper objectMapper = JSONUtil.prettyMapper();
  objectMapper.registerModule(
    new SimpleModule()
      .addDeserializer(JobDataFragment.class,
        new JsonDeserializer<JobDataFragment>() {
          @Override
          public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
            return jsonParser.readValueAs(DataPOJO.class);
          }
        }
      )
  );
  provider.setMapper(objectMapper);
  masterClient = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build();
  WebTarget rootTarget = masterClient.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort());
  masterApiV2 = rootTarget.path(API_LOCATION);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:TestMasterDown.java

示例8: getResult

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
public Result getResult(WebTarget target) {
  WebTarget t = target;
  target.path(Joiner.on(",").join(indexes)).path("_mapping");
  if (indexes.size() > 0) {
    t = t.path(Joiner.on(",").join(indexes));
  }
  t = t.path("_mapping");
  if (types.size() > 0) {
    t = t.path(Joiner.on(",").join(types));
  }
  try {
    return new JsonResult(t.request().buildGet().invoke(byte[].class));
  } catch (WebApplicationException e) {
    return new FailureResult(e.getResponse().getStatus(), e.getMessage());
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:ElasticTestActions.java

示例9: main

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
 
     try {
         //Client client = Client.create();
         // Accept self-signed certificates
         Client client = createClient();

         String username = "user";
         String password = "password";
         //client.addFilter(new HTTPBasicAuthFilter(username, password));
         HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(username, password);
         client.register(feature);
         
         WebTarget webResource = client.target("https://localhost:8443");
         WebTarget webResourceWithPath = webResource.path("ss7fw_api/1.0/eval_sccp_message_in_ids");
         WebTarget webResourceWithQueryParam = webResourceWithPath.matrixParam("sccp_raw", "12345");
         
         System.out.println(webResourceWithQueryParam);
         
         //ClientResponse response = webResourceWithQueryParam.accept("text/plain").get(ClientResponse.class);
         Response response = webResourceWithQueryParam.request("text/plain").get();
         
         if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
         }

         String output = response.readEntity(String.class);

         System.out.println("Output from Server .... \n");
         System.out.println(output);

} catch (Exception e) {
           e.printStackTrace();
}
     
 }
 
开发者ID:P1sec,项目名称:SigFW,代码行数:37,代码来源:RestClientTest.java

示例10: sayHelloNameTest

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
@Test
public void sayHelloNameTest() {
    WebTarget target = client.target(REST_URI);
    WebTarget targetUpdated = target.path("/tastjava");
    String response = targetUpdated.request(MediaType.TEXT_PLAIN_TYPE).get(String.class);
    assertEquals("OK", response);
}
 
开发者ID:xujiajun,项目名称:tastjava,代码行数:8,代码来源:HelloResourceTest.java

示例11: getWebTarget

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
private WebTarget getWebTarget(String[] pathItem, KeyValue[] queryParams) {
    WebTarget result = basePath;
    for (String item : pathItem) {
        result = result.path(item.replace(SERVICE_PLACEHOLDER, serviceName));
    }

    for (KeyValue param : queryParams) {
        result = result.queryParam(param.key, param.value);
    }

    return result;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:13,代码来源:ExternalEndpointRedirectorEnvLoader.java

示例12: tccCoordinatorClient

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
@Bean
public WebTarget tccCoordinatorClient() {
	Client client = ClientBuilder.newClient();
	client.register(new JacksonJaxbJsonProvider());
	client.register(new TransactionProvider());
	WebTarget target = client.target(tccCoordinatorBaseUrl);
	return target.path("/coordinator");
}
 
开发者ID:jotorren,项目名称:microservices-transactions-tcc,代码行数:9,代码来源:CompositeTransactionConfiguration.java

示例13: buildRequest

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
@Override
Invocation buildRequest(WebTarget target, ContextListener context) {
  target = target.path("_cluster/state/metadata");
  if(indexName != null){
    target = target.path(indexName);
  }

  context.addContext(target);
  return target.request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:ElasticActions.java

示例14: sendOrder

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
public String sendOrder(String return_url,
        String version, String current_locale,
        String currency_code, String command,
        String merchant_trans_id, String country_code,
        String good_code, String xml_description,
        String net_cost, String ship_fee, String tax,
        String merchant_code,
        String service_code, String secure_hash,
        String desc_1, String desc_2, String desc_3,
        String desc_4, String desc_5, String internal_bank) throws ClientErrorException {
    WebTarget resource = webTarget;
    if (return_url != null) {
        resource = resource.queryParam("return_url", return_url);
    }
    if (version != null) {
        resource = resource.queryParam("version", version);
    }
    if (current_locale != null) {
        resource = resource.queryParam("current_locale", current_locale);
    }
    if (currency_code != null) {
        resource = resource.queryParam("currency_code", currency_code);
    }
    if (command != null) {
        resource = resource.queryParam("command", command);
    }
    if (country_code != null) {
        resource = resource.queryParam("country_code", country_code);
    }
    if (xml_description != null) {
        resource = resource.queryParam("xml_description", xml_description);
    }
    if (net_cost != null) {
        resource = resource.queryParam("net_cost", net_cost);
    }
    if (ship_fee != null) {
        resource = resource.queryParam("ship_fee", ship_fee);
    }
    if (tax != null) {
        resource = resource.queryParam("tax", tax);
    }
    if (service_code != null) {
        resource = resource.queryParam("service_code", service_code);
    }
    if (desc_1 != null) {
        resource = resource.queryParam("desc_1", desc_1);
    }
    if (desc_2 != null) {
        resource = resource.queryParam("desc_2", desc_2);
    }
    if (desc_3 != null) {
        resource = resource.queryParam("desc_3", desc_3);
    }
    if (desc_4 != null) {
        resource = resource.queryParam("desc_4", desc_4);
    }
    if (desc_5 != null) {
        resource = resource.queryParam("desc_5", desc_5);
    }
    if (internal_bank != null) {
        resource = resource.queryParam("internal_bank", internal_bank);
    }

    if (merchant_code != null) {
        resource = resource.queryParam("merchant_code", merchant_code);
    }
    if (good_code != null) {
        resource = resource.queryParam("good_code", good_code);
    }
    if (merchant_trans_id != null) {
        resource = resource.queryParam("merchant_trans_id", merchant_trans_id);
    }
    if (secure_hash != null) {
        resource = resource.queryParam("secure_hash", secure_hash);
    }

    resource = resource.path("sendOrder");
    return resource.request(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:80,代码来源:KPRest.java

示例15: sendOrder

import javax.ws.rs.client.WebTarget; //导入方法依赖的package包/类
public String sendOrder(String return_url, String version, String current_locale, String currency_code,
		String command, String merchant_trans_id, String country_code, String good_code, String xml_description,
		String net_cost, String ship_fee, String tax, String merchant_code, String service_code, String secure_hash,
		String desc_1, String desc_2, String desc_3, String desc_4, String desc_5, String internal_bank)
		throws ClientErrorException {
	WebTarget resource = webTarget;
	if (merchant_code != null) {
		resource = resource.queryParam("merchant_code", merchant_code);
	}
	if (good_code != null) {
		resource = resource.queryParam("good_code", good_code);
	}
	if (xml_description != null) {
		resource = resource.queryParam("xml_description", xml_description);
	}
	if (internal_bank != null) {
		resource = resource.queryParam("internal_bank", internal_bank);
	}
	if (merchant_trans_id != null) {
		resource = resource.queryParam("merchant_trans_id", merchant_trans_id);
	}
	if (current_locale != null) {
		resource = resource.queryParam("current_locale", current_locale);
	}
	if (tax != null) {
		resource = resource.queryParam("tax", tax);
	}
	if (desc_1 != null) {
		resource = resource.queryParam("desc_1", desc_1);
	}
	if (desc_3 != null) {
		resource = resource.queryParam("desc_3", desc_3);
	}
	if (version != null) {
		resource = resource.queryParam("version", version);
	}
	if (desc_2 != null) {
		resource = resource.queryParam("desc_2", desc_2);
	}
	if (currency_code != null) {
		resource = resource.queryParam("currency_code", currency_code);
	}
	if (command != null) {
		resource = resource.queryParam("command", command);
	}
	if (desc_5 != null) {
		resource = resource.queryParam("desc_5", desc_5);
	}
	if (desc_4 != null) {
		resource = resource.queryParam("desc_4", desc_4);
	}
	if (ship_fee != null) {
		resource = resource.queryParam("ship_fee", ship_fee);
	}
	if (country_code != null) {
		resource = resource.queryParam("country_code", country_code);
	}
	if (secure_hash != null) {
		resource = resource.queryParam("secure_hash", secure_hash);
	}
	if (return_url != null) {
		resource = resource.queryParam("return_url", return_url);
	}
	if (service_code != null) {
		resource = resource.queryParam("service_code", service_code);
	}
	if (net_cost != null) {
		resource = resource.queryParam("net_cost", net_cost);
	}
	resource = resource.path("sendOrder");
	return resource.request(javax.ws.rs.core.MediaType.APPLICATION_JSON).get(String.class);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:73,代码来源:KPJsonRest.java


注:本文中的javax.ws.rs.client.WebTarget.path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。