0

我想使用 restlet 来消费一个休息网络服务。这将通过一个帖子来完成。我需要在以下代码中添加什么:

ClientResource resource = new ClientResource("url");      
resource.setChallengeResponse(ChallengeScheme.HTTP_BASIC, user, password);

我有一个 Json 字符串,在实现我的 rest-webservice 的代码中,输入是一个表示对象。如果可能的话,我需要我的参数(作为 jsonstring)在 entity.gettext() 方法中。

public StartProcessInstanceResponse startProcessInstance(Representation entity)
jsonstring = entity.gettext();

提前致谢。

4

1 回答 1

1

自己找到了答案......你应该像这样制作一个表示对象

Representation rep = new StringRepresentation(jsonString);

然后你可以像这样发布:

resource.post(rep);

而已...

于 2012-05-03T09:10:47.100 回答