문제

i have a json string which is :

`{
    "portfolio": "HEXGENFUND",
    "transSrlNo": "1",
    "transCode": "BUY",
    "investReason": "004",
    "inflowOutflow": "I",
    "transDate": "2012-09-01",
    "tradeDate": "2012-09-01",
    "tradeDateUpto": "2012-09-01",
    "tradeTime": "11:27:9",
    "investCategory": "FVTPL",
    "custodian": "DEUTSCHE",
    "holdType": "HOLD",
    "securityType": "INV",
    "security": "DABU02",
    "assetClass": "EQU",
    "issuer": "DABU",
    "marketType": "MKT",
    "tradePriceType": "S",
    "requisitionType": "SO",
    "priceFrom": "100000",
    "priceTo": "100000",
    "marketPrice": "100000",
    "averagePrice": "100000",
    "price": "100000",
    "quantity": "2",
    "grossAmtTcy": "200000",
    "exchRate": "1",
    "grossAmtPcy": 200000,
    "grossIntTcy": "0",
    "grossIntPcy": 0,
    "netAmountTcy": 200000,
    "netAmountPcy": 200000,
    "acquCostTcy": 200000,
    "acquCostPcy": 200000,
    "yieldType": "N",
    "purchaseYield": "0",
    "marketYield": "0",
    "ytm": "0",
    "mduration": "0",
    "currPerNav": "0",
    "desiredPerNav": "0",
    "currHolding": "0",
    "noofDays": "0",
    "realGlPcy": 0,
    "realGlTcy": "0",
    "nowLater": "N",
    "isAllocable": "false",
    "acquCostReval": 0,
    "acquCostHisTcy": 200000,
    "acquCostHisPcy": 0,
    "exIntTcy": 0,
    "exIntPcy": 0,
    "accrIntReval": 0,
    "accrIntTcy": 0,
    "accrIntPcy": 0,
    "grossAodTcy": 0,
    "grossAodPcy": 0,
    "grossAodReval": 0,
    "bankAccAmtAcy": 200000,
    "bankAccAmtPcy": 200000,
    "taxAmountTcy": 0,
    "unrelAmortTcy": 0,
    "unrelAmortPcy": 0,
    "unrelGlTcy": 0,
    "unrelGlPcy": 0,
    "realGlHisTcy": 0,
    "realGlHisPcy": 0,
    "tradeFeesTcy": 0,
    "tradeFeesPcy": 0
}`

i try to call the method which takes the above parameter through httpclient. when i call the method like the below :

uri = "http://localhost:8080/api/trade/createrequisition";
HttpPost postURI = new HttpPost(uri);
            postURI.setHeader("Content-type", "application/json");
            // Setup the request parameters
            BasicHttpParams params = new BasicHttpParams();
            params.setParameter("CreateRequisitionRO", jsonROConverter.serialiseRequisionRO(request));
            params.setBooleanParameter("validateOnly", validateOnly);
            postURI.setParams(params);

            HttpResponse responseURL = client.execute(postURI);

this is what is the signature of the method called:

public @ResponseBody
    void createRequisition(@RequestBody CreateRequisitionRO[] request,
            @RequestHeader("validateOnly") boolean validateOnly) {....}

this the exception i get :

java.io.EOFException: No content to map to Object due to end of input

What could be the problem.

Please help me to fix this.

도움이 되었습니까?

해결책

StringRequestEntity requestEntity = new StringRequestEntity(
    JSON_STRING,
    "application/json",
    "UTF-8");

PostMethod postMethod = new PostMethod("http://localhost:8080/api/trade/createrequisition");
postMethod.setRequestEntity(requestEntity);

int statusCode = httpClient.executeMethod(postMethod);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top