简体   繁体   English

称为另一休息并响应“ 400错误请求”的休息

[英]A rest that call another rest and response “400 bad request”

I'm programming in Java a REST that calls another REST. 我在用Java编程的REST调用另一个REST。 The response from the second REST is transformed into a object and added into a List, and when the List has 12 elements, the REST response should be "400 bad request". 来自第二个REST的响应被转换为对象并添加到List中,并且当List具有12个元素时,REST响应应为“ 400错误请求”。

I'm receiving the error in the GET of this method. 我在此方法的GET中收到错误。 I have a foreach that calls this method 20 times. 我有一个foreach ,调用此方法20次。 The first 11 times work, but the 12th time I receive the bad request. 前11次工作,但第12次收到错误请求。

Client call: 客户电话:

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 code: 输入代码:

@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)

Did you try replacing 您是否尝试更换

.request()

By: 通过:

.request(MediaType.APPLICATION_JSON_TYPE)

And don't forget the import: 并且不要忘记导入:

import javax.ws.rs.core.MediaType;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM