您好,我正在开发一个应用程序,其中使用 Flex 用于 GUI,使用 Restlet 用于 Web 服务。我有一个奇怪的问题。我将 XML 作为通用对象的属性,并将其作为 POST 请求的一部分发送。但在 Restlet Web 服务中,此 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();

.

.

} catch(异常E)

{e.printstacktrace();}

它在 dom.getDocument() 行抛出空指针异常。这意味着没有数据实际到达。

和我的Flex位看起来像这样-VAR服务:HTTPService = 新的 HTTPService();service.method =“POST”;
service.conttype =“ application/xml” service.url = url;var token :AsyncToken = service.send(params);

其中 params 是一个 XML 对象。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top