【问题标题】:Apache Wink 1.2.1 conditional call service methodApache Wink 1.2.1 条件调用服务方法
【发布时间】:2014-02-03 11:39:18
【问题描述】:

我在尝试调用服务方法并在此之前检查某些条件时遇到了问题

@Path("service")
public class MyService {

    @POST
    @Path("process")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Produces(MediaType.TEXT_PLAIN)
    public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException {
        boolean someCondition =  true; // for example
        System.out.println("I'm here"); //*
        if (!someCondition) {
            return MyClass1.process(request, text);
        } else {
            return MyClass2.process(request, text);
        }
    }

在 MyClass1 和 MyClass2 类中,我有下一个方法签名

public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException 

调用此方法服务时未找到响应,甚至没有打印带有 * 注释的行。

我该如何解决这个问题?

【问题讨论】:

  • 您的服务可能尚未注册。您需要在启动服务器时检查日志以确保您的 MyService 类已注册。

标签: java web-services rest apache-wink


【解决方案1】:

我犯了一个非常愚蠢的错误静态方法:

 public static Response process(@Context HttpServletRequest request, @FormParam("text") final String text) throws JSONException, IOException {

【讨论】:

    猜你喜欢
    • 2013-09-04
    • 1970-01-01
    • 2011-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多