这是我的impl课程:
@Path("/initiatePayment1")
public class InitiatePaymentImpl {
private Logger logger = Logger.getLogger(getClass());
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public InitiatePaymentResponse initiatePayment(InitiatePaymentReq req){
logger.debug("Inside the initiatePayment in gateway.");
logger.debug("Initiate Request Object is : " + req.toString());
InitiatePaymentResponse res = new InitiatePaymentResponse();
res.setResponseCode("E0000");
res.setResponseString("Well Done..");
return res;
}
}
以下是我的两个pojo课程:
package com.empays.dto;
import java.util.Date;
public class InitiatePaymentReq {
public InitiatePaymentReq() {
}
public InitiatePaymentReq(String senderMobileNo) {
super();
this.senderMobileNo = senderMobileNo;
}
private String senderMobileNo=null;
public String getSenderMobileNo() {
return senderMobileNo;
}
public void setSenderMobileNo(String senderMobileNo) {
this.senderMobileNo = senderMobileNo;
}
*/
@Override
public String toString() {
return "senderMobileNo=" +senderMobileNo;
}
}
其他POJO calss:
package com.empays.dto;
import java.util.Calendar;
import java.util.Date;
public class InitiatePaymentResponse {
public InitiatePaymentResponse() {
}
public InitiatePaymentResponse(String responseCode, String responseString) {
super();
this.responseCode = responseCode;
this.responseString = responseString;
}
private String responseCode;
private String responseString;
public String getResponseCode() {
return responseCode;
}
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
public String getResponseString() {
return responseString;
}
public void setResponseString(String responseString) {
this.responseString = responseString;
}
@Override
public String toString() {
return "responseCode=" + responseCode + ", responseString=" + responseString;
}
}
从httprequester,我打电话给班级:
http://localhost:8080/Test/initiatePayment1
Contenttype = application / json
和参数{"senderMobileNo":"9820175762"}
调用它后会给出:
输入状态报告
消息错误请求
description客户端发送的请求在语法上是不正确的。