我在Java中编程一个调用另一个REST的REST。第二个REST的响应转换为一个对象并添加到一个List中,当List有12个元素时,REST响应应该是" 400个错误请求"。
我在此方法的GET中收到错误。我有foreach
调用此方法20次。前11次工作,但第12次我收到了错误的请求。
客户来电:
private String callAcountingDebitCreditServiceAcount(
long originalOption, long codeInstance, long codeCompany, String codeBranch,
String codeOffice, String currency, String inputCost, long operationNumber,
String jsonResult, long originalOptionMenu, long codeTrans, String tableName,
String pkJson)
throws UnsupportedEncodingException, IOException {
String jsonFuente = jsonResult;
jsonFuente = URLEncoder.encode(jsonFuente, "utf-8");
String pkj = URLEncoder.encode(pkJson, "utf-8");
String URLrest = "http://llacsaa-server:9080/JorupeInstanceWS/webresources/accountingDebitCreditService";
String respuestaStr = ClientBuilder.newClient()
.target(URLrest)
.queryParam("codeInstance", codeInstance)
.queryParam("codeCompany", codeCompany)
.queryParam("codeTrans", codeTrans)
.queryParam("codeBrach", codeBranch)
.queryParam("codeOffice", codeOffice)
.queryParam("originalOption", originalOption)
.queryParam("currency", currency)
.queryParam("inputCost", inputCost)
.queryParam("operationNumber", operationNumber)
.queryParam("jsonArrayScreen", jsonFuente)
.queryParam("originalOptionMenu", originalOptionMenu)
.queryParam("tableName", tableName)
.queryParam("pkJson", pkj)
.request()
.get(String.class);
ResponseRest respuesta = new ResponseRest();
return respuesta.process(respuestaStr).toString();
}
Enpoint代码:
@Stateless
@Path("accountingDebitCreditService")
public class AccountingDebitCreditREST {
@Inject
private ServiceRegistry services;
@GET
@Produces(MediaType.APPLICATION_JSON)
public ResponseRest accountingDebitCredit(
@QueryParam("originalOption") long originalOption,
@QueryParam("codeInstance") long codeInstance,
@QueryParam("codeCompany") long codeCompany,
@QueryParam("codeBrach") String codeBranch,
@QueryParam("codeOffice") String codeOffice,
@QueryParam("currency") String currency,
@QueryParam("inputCost") String inputCost,
@QueryParam("operationNumber") long operationNumber,
@QueryParam("jsonArrayScreen") String jsonArrayScreen,
@QueryParam("originalOptionMenu") long originalOptionMenu,
@QueryParam("codeTrans") long codeTrans,
@QueryParam("tableName") String tableName,
@QueryParam("pkJson") String pkJson)
答案 0 :(得分:1)
您是否尝试更换
.request()
人:
.request(MediaType.APPLICATION_JSON_TYPE)
不要忘记导入:
import javax.ws.rs.core.MediaType;