一尘不染

从浏览器调用REST Web服务URL

tomcat

我已经部署了简单的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。


阅读 758

收藏
2020-06-16

共1个答案

一尘不染

这是路径参数。因此,我认为该网址应为:

http://localhost:8080/Engine/services/Evaluation/initializeEvaluation/en-GB
2020-06-16