本文整理匯總了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;
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
}
示例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();
}
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}