您好我正在开发一个用于 GUI 的 Flex 和用于 Web 服务的 Restlet 的应用程序。我有一个奇怪的问题。我将我的 XML 作为一个通用对象的属性,并将其作为 POST 请求的一部分发送。但是在 Restlet webservice 中,这个 XML 是不可恢复的。我该如何找回它?我尝试将收到的 Representation 对象初始化为 DomRepresentation,但这不起作用。如果我将接收到的 Representation 对象放入 Form 对象中,那么 getFirstValue 会将该 XML 作为字符串返回!
我注意到 HTTPService 的 contentType 是 application/www-form-encoded 所以我将它设置为 application/xml 并且它也没有帮助。
我使用restlet 2.0m6,这是我使用的代码片段 -
@邮政
公共代表过程(代表实体)
{
尝试
{
DomRepresentation dom = new DomRepresentation(entity);
文档 d = dom.getDocument();
.
.
} 捕捉(异常 e)
{ e.printStackTrace(); }
它会在 dom.getDocument() 行引发空指针异常。这意味着实际上没有数据到达。
我的弹性位看起来像这样 - var service : HTTPService = new HTTPService(); service.method="POST";
service.contentType="应用程序/xml" service.url=url; var token :AsyncToken = service.send(params);
其中 params 是一个 XML 对象。