Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何进行动态RESTful服务调用?_Java_Web Services_Jax Rs - Fatal编程技术网

Java 如何进行动态RESTful服务调用?

Java 如何进行动态RESTful服务调用?,java,web-services,jax-rs,Java,Web Services,Jax Rs,我想打一个RESTfulWebService电话给 如何在请求字符串中形成动态属性?以下是我尝试过但不起作用的内容: Client client = ClientBuilder.newClient(); client.property("hotelnr", 41748); //works not (HTTP 404 Not Found): client.target("http://www.cleartrip.com/places/hotels/info/{hotelnr}").request

我想打一个RESTfulWebService电话给

如何在请求字符串中形成动态属性?以下是我尝试过但不起作用的内容:

Client client = ClientBuilder.newClient();
client.property("hotelnr", 41748);

//works not (HTTP 404 Not Found):
client.target("http://www.cleartrip.com/places/hotels/info/{hotelnr}").request(MediaType.APPLICATION_XML).get();

//works:
client.target("http://www.cleartrip.com/places/hotels/info/41748").request(MediaType.APPLICATION_XML).get();
看看:

您可以执行以下操作:

WebTarget myResource = client.target("http://example.com/webapi/read")
  .path("{userName}");
Response response = myResource.queryParam("userName", "janedoe")
  .request(...)
  .get();
看看:

您可以执行以下操作:

WebTarget myResource = client.target("http://example.com/webapi/read")
  .path("{userName}");
Response response = myResource.queryParam("userName", "janedoe")
  .request(...)
  .get();

您使用什么
Client
客户端?您使用什么
Client
客户端?这解决了您的问题吗?如果是这样,你应该结束这个问题。这解决了你的问题吗?如果是这样,你应该结束这个问题。