【发布时间】: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