java - ReSTLet 使用 post web 服务,添加 json 字符串作为表示

标签 java web-services rest restlet

我想使用 ReSTLet 来使用 Rest Web 服务。这将通过帖子完成。 我需要在以下代码中添加什么:

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

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

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

提前致谢。

最佳答案

我自己找到了答案... 您应该创建一个像这样的 Representation 对象

Representation rep = new StringRepresentation(jsonString);

然后你可以像这样发帖:

resource.post(rep);

就是这样...

关于java - ReSTLet 使用 post web 服务,添加 json 字符串作为表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10416513/

相关文章:

javascript - REST API 创建一个或多个资源?

javascript - 删除 View 时取消所有传出的 REST HTTP 请求

java - Spring Data @CreatedDate 注释对我不起作用

java - 录音错误

java - 如何将 requestdispatcher 转发到远程 URL

c# - 如何从 C# 中的另一个项目调用或启动 asp.net web 服务 (asmx)

mysql - 如何使用带有双向实体的 RestFul Web 服务正确编写 Json?

java - 同步代码块

java - 使用Java运行cmd命令

asp.net-mvc-3 - 使用 Windows 身份验证获取 WCF 中当前交互用户的用户名,包括 Rest Endpoint 和 MVC3