2

我已经部署了简单的 REST 接口。假设我的 REST 服务部署在此上下文路径中:

http://localhost:8080/Engine/services/Evaluation

然后我像这样调用 URL:

http://localhost:8080/Engine/services/Evaluation?_wadl

我可以看到 XML 输出:

<application>
    <grammars/>
    <resources base="http://localhost:8080/Engine/services/Evaluation">
        <resource path="/Evaluation/">
            <resource path="initializeEvaluation/{localeCode}">
                <param name="localeCode" style="template" type="xs:string"/>
                <method name="GET">
                    <request>
                        <representation mediaType="application/octet-stream"/>
                    </request>
                    <response>
                        <representation mediaType="application/json"/>
                    </response>
                </method>
            </resource>
        </resource>
    </resources>
</application>

问题是如何从浏览器调用带有 URL 的方法?

我试图输入:

http://localhost:8080/Engine/services/Evaluation/initializeEvaluation?localeCode=en-GB

但我有:

2013-01-30 11:22:13,477 [http-bio-8080-exec-3] WARN   JAXRSInInterceptor - No root resource matching request path /Engine/services/Evaluation/initializeEvaluation has been found, Relative Path: /initializeEvaluation. Please enable FINE/TRACE log level for more details.
2013-01-30 11:22:13,479 [http-bio-8080-exec-3] WARN   WebApplicationExceptionMapper - javax.ws.rs.NotFoundException

我是 REST 的新手,但据我所知,URL 应该像上面那样。那为什么我会遇到异常?

我的java接口:

@Path("/Evaluation/")
@Produces(MediaType.APPLICATION_JSON)
public interface EvaluationService {

    @GET
    @Path("initializeEvaluation/{localeCode}")
    EvaluationStatus initializeEvaluation(ClientType client, @PathParam("localeCode") String localeCode)
            throws EvaluationException;

}

我正在使用 Apache CXF 2.7.0、JDK 1.7、Tomcat 7。

4

3 回答 3

3

这是一个路径参数。因此,我认为 URL 应该是:

http://localhost:8080/Engine/services/Evaluation/initializeEvaluation/en-GB
于 2013-01-30T15:01:29.830 回答
1

您的 @Path 注释中缺少 / 。

@Path("/initializeEvaluation/{localeCode}")
于 2013-01-30T11:33:06.507 回答
0

使用RestClient插件,它让你的生活更轻松。

于 2013-01-30T11:32:08.373 回答