2

使用 play WS 调用 Web 服务时,它正在抛出

[RuntimeException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: org.jboss.netty.buffer.ChannelBufferInputStream@1fecc4f; line: 1, column: 2]]

环境:Ubuntu 12.04 + Java 1.7 + Play Framework 2.2.0

4

1 回答 1

2

此异常实际上JsonParseException意味着String您实际尝试解析的不是有效的 JSON。出现此问题是因为接收到的响应是 XML 或 HTML 格式,并且包含<服务不可用时常见的字符和类型的响应

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /123 was not found on this server.</p>
<p>Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

或者

<data contentType="null" contentLength="0"><![CDATA[]]></data>

在将其与 Play 框架集成之前,请尝试通过 SOAP UI 或 PostMan 等 REST 客户端调用 Web 服务。

于 2013-10-11T06:51:45.920 回答