1

I cannot seem to find anything on the subject on the site of restlet or anywhere on how to add parameters to a webservice call.

I am able to use restlet to call a webservice that doesn't need any parameters and handle the respond.

If you know any other frameworks that are able to call a webservice and pass parameters(rest) please tell me.

Thanks in advance.

4

2 回答 2

2

要使用 Restlet(2.3 版)向 Web 服务调用添加查询参数,您可以执行以下操作:

// Create a client resource which will call a given service
ClientResource clientResource = new ClientResource("http://serviceToCall.com");

// Add a query parameter
clientResource.addQueryParameter("queryParameterName", "queryParameterValue");

// Make a "GET"
clientResource.get();

这是相应的Javadocs

于 2015-08-12T10:02:16.623 回答
1

试试这个。基于来自Restlet wiki的示例:

// Create the client resource  
ClientResource resource = new ClientResource("http://www.restlet.org");  

// Add a query parameter equiv to ?A=1
resource.getReference().addQueryParameter("A","1"); 

// Customize the referrer property  
resource.setReferrerRef("http://www.mysite.org");  

// Write the response entity on the console
resource.get().write(System.out);  
于 2012-05-02T12:20:53.253 回答