我想使用 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/