【问题标题】:Post method is not working while migrating one maching to other machine将一台机器迁移到另一台机器时,发布方法不起作用
【发布时间】:2015-05-08 06:25:35
【问题描述】:

从一台机器迁移restfull应用程序到另一台机器后,我们只能访问GET类型的方法,但我们无法访问POST类型的方法。我正在使用 Tomcat 6.0.36。请对此提供帮助。 请找到我正在使用的代码。

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.annotations.ResponseObject;
import org.json.JSONObject;

import com.Clients.MobileAPIClient;

@Path("/MobileAppFNOLAPI")
public class MobileAppFNOLAPI {


@GET
@Path("/getClaims")
public JSONObject getClaims(
    @QueryParam("input") String input) {

    String getClaims = null;

    JSONObject jsonObject = null;

    System.out.println("inside getClaims()"+input);

    MobileAPIClient mobileAPIClient = new MobileAPIClient();
    try {

        getClaims = mobileAPIClient.callPersonalAPI().getClaims(input);

        System.out.println(getClaims);

        jsonObject = new JSONObject(getClaims);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return jsonObject;

}


@GET
@Path("/getClaimStatus")
public JSONObject getClaimStatus(
    @QueryParam("input") String input) {

    System.out.println("inside getClaimStatus()"+input);

    String claimStatus = null;

    JSONObject jsonObject = null;

    // Write the business Logic and return the output finally

    MobileAPIClient mobileAPIClient = new MobileAPIClient();
    try {
        claimStatus = mobileAPIClient.callPersonalAPI().getClaimStatus(input);
        jsonObject = new JSONObject(claimStatus);
        System.out.println(claimStatus);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    return jsonObject;

}


@POST
@Path("/savePortalClaim/{xmlInput}")

        public JSONObject savePortalClaim (@PathParam("xmlInput") String xmlInput) {
    String saveClaimStatus = null;
    JSONObject jsonObject = null;
    System.out.println("inside savePortalClaim() "+xmlInput);

    MobileAPIClient mobileAPIClient = new MobileAPIClient();
    try {
         saveClaimStatus = mobileAPIClient.callPersonalAPI().savePortalClaim(xmlInput);
         jsonObject = new JSONObject(saveClaimStatus);
         System.out.println(saveClaimStatus);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // Write the business Logic and return the output finally
    return jsonObject;
}
@GET
@Path("/doesPolicyExists")
public JSONObject doesPolicyExists(@QueryParam("policyNumber") String policyNumber,@QueryParam("password") String password) {

System.out.println("inside doesPolicyExists()"+policyNumber);
System.out.println("inside doesPolicyExists()"+password);

//String policyNumber = null
JSONObject jsonObject = null;

// Write the business Logic and return the output finally

MobileAPIClient mobileAPIClient = new MobileAPIClient();
try {
    System.out.println("startinggggggggggggggggggggggggggggggggggggggggg");
   String  policyResult = mobileAPIClient.callPersonalAPI().doesPolicyExists(policyNumber, password);
    System.out.println("policyResult--------------------------->"+policyResult); 
    jsonObject = new JSONObject(policyResult);

} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}


return jsonObject;

}}

【问题讨论】:

  • 请提供更多信息。您正在使用REST 的什么实现,您的机器是什么,代码是什么以及所有其他相关信息
  • 感谢您的回复。我已经发布了代码。我正在使用window 7机器。

标签: java tomcat restful-url


【解决方案1】:
  • 可能是,在一台机器上启用了 HTTP VERB POST,但在不工作的机器上却没有。

  • 值得检查机器之间的 TOMCAT Web 服务器配置。

【讨论】:

  • 在 web.xml 我使用了以下代码 Ressources REST/*OPTIONSPUTPOST TRACE*
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-10-15
  • 1970-01-01
  • 1970-01-01
  • 2019-05-18
  • 1970-01-01
  • 2014-11-02
  • 1970-01-01
相关资源
最近更新 更多