안녕하세요 저는 grails에서 POST를하려고하는데 2 가지 방법을 시도했습니다. 나는이 curl 명령을 복제 걸려 :grails의 POST가 작동하지 않습니다.
curl -F [email protected] http://server.com/service.pl > out.xml
이 명령은 잘 작동합니다.
def actualInputFile = new File("/path/to/file/in.xml");
def http = new HTTPBuilder('http://server.com/service.pl')
println "START POST"
def postBody = [upload:actualInputFile] // will be url-encoded
http.post(body: postBody,
requestContentType: XML) { resp ->
println "POST Success: ${resp.statusLine}"
}
이 그냥 전혀 작동하지 않습니다
는def actualInputFile = new File("/path/to/file/in.xml");
def retval = [success: false, message: null];
HttpClient postClient = new HttpClient();
MultipartPostMethod postMethod = new MultipartPostMethod('http://server.com/service.pl');
postClient.httpConnectionManager.getParams().setSoTimeout(300000);
postMethod.addParameter("upload",actualInputFile);
int status = postClient.executeMethod(postMethod);
def data = postMethod.getResponseBodyAsString();
postMethod.releaseConnection();
def returnedFile = new File("/path/to/file/out.xml");
returnedFile.write(data);
이 500 오류 나는 또한 시도
에게 제공 : 내가 지금까지 시도 무엇 는 다음과 같습니다.
500 개 용도를 얻는 첫번째
메소드 절하.어떤 아이디어가 있습니까?