2012-01-04 3 views
0

헤더 매개 변수 및 양식 매개 변수를 사용하여 REST 웹 서비스에 POST 요청을해야합니다. 내가 보낼 필요가 헤더와 형태 PARAMS의REST 웹 서비스 POST 메서드 헤더 및 양식 매개 변수

Method: POST/
Produces: application/json/
Consume: application/x-www-form-urlencoded/and etc. 

및 목록 : I는 웹 서비스 방법에 대한 설명이있다.

생산 및 소비가 무엇이고 요청을 구성하는 방법을 누구나 명확하게 설명 할 수 있습니까?

나는 undestand : httpPost = new HttpPost (webServiceUrl + methodName);

httpPost.setHeader("headerParamName", headerParam); 
    entity = jsonObject.put(param.getKey(), param.getValue());//param - form param 
    httpPost.setEntity(entity); 
    httpPost.setHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF8"); //??? 

미안하지만 질문이 있으면 미안합니다.

+0

몇 가지 추가 정보를 추가해야합니까? – user1074896

답변

2

생산물은 웹 서비스가 반환 할 데이터 유형이어야합니다. 즉, 웹 서비스가 수신해야하는 데이터 유형이어야합니다 (즉, 메소드가 수신하는 데이터 유형 임). , 메서드에서 전달하는 데이터). 다음과 같이 설정해야합니다.

httpPost.setHeader("Accept", "application/json"); 
httpPost.setHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF8"); 
+0

http://stackoverflow.com/questions/8727672/how-send-form-params-to-rest-web-service-through-http-client – user1074896