1

WCFサービスから、AndroidをクライアントとしてDateTime(Joda DateTime)でフィルタリングされているオブジェクトのリストを取得しようとしています。リクエストを行うためにJsonとRESTを使用しています。

日時の値をパラメーターとして渡すにはどうすればよいですか?

何かのようなもの:

HttpPost request = new HttpPost( SERVICE_URI + "/GetScheduleEntrysByDate/" + date.toString());

この:

[OperationContract]
[WebInvoke(Method = "POST",
    UriTemplate = "GetScheduleEntrysByDate/{date}",
    BodyStyle = WebMessageBodyStyle.WrappedRequest,
    ResponseFormat = WebMessageFormat.Json,
    RequestFormat = WebMessageFormat.Json)]
List<ScheduleEntry> GetScheduleEntrysByDate(DateTime date);
4

1 に答える 1

0
// you might wanna specify custom params here for the DefaultHttpClient contructor
DefaultHttpClient httpClient = new DefaultHttpClient();

HttpPost request = new HttpPost( SERVICE_URI + "/GetScheduleEntrysByDate/" + date.toString());

List<NameValuePair> bodyParams = new ArrayList<NameValuePair>();
bodyParams.add(new BasicNameValuePair("date", new Date().getTime());
if (bodyParams.size() > 0) {
    try {
        // Include the request body
        post.setEntity(new UrlEncodedFormEntity(bodyParams));
    } catch (UnsupportedEncodingException e) {
        throw new IllegalStateException("Body parameters produced unsupported encoding?", e);
    }
}
// sends the POST with params,  you will need to put this in a try catch
try {
    HttpResponse httpResponse = httpClient.execute(request);
} catch (Exception e){
}
于 2012-11-09T17:27:26.667 に答える