将日期时间从Android发送到Web服务.Net

时间:2013-11-15 05:01:25

标签: android .net web-services datetime ksoap2

为什么当我把这个日期放在这个格式2013-11-14 00:00:00失败我的android应用程序时 并告诉我这个错误:

java.io.IOException: HTTP request failed, HTTP status: 500.

但是当我把这种格式2013-11-14正常工作时。

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_FRES);   
            PropertyInfo pi = new PropertyInfo();
            pi.type = PropertyInfo.STRING_CLASS;
            //adding parameters
            **request.addProperty("fechaConsultar", Fecha);**
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            envelope.setOutputSoapObject(request);
            HttpTransportSE transporte = new HttpTransportSE(URL, 30000);

Fecha是日期格式的字符串。 我的WebService检索Datetime对象。 这是我的网络服务

    public List<FechaReservada> fechasReservadas(DateTime fechaConsultar)
    {
        return consultaFecha(fechaConsultar);

    }

    public List<FechaReservada> consultaFecha(DateTime fecha)
    {
        MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["ConexionMysql"].ConnectionString);
        List<FechaReservada> result = new List<FechaReservada>();
        FechaReservada fec;
        try
        {
            con.Open();
            MySqlCommand cmd = new MySqlCommand("g_getSalonesbyFecha", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("Fecha",fecha);
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
            DataTable ds = new DataTable();
            da.Fill(ds);
            foreach (DataRow dr in ds.Rows)
            {
                fec = new FechaReservada();
                fec.Sucursal = int.Parse(dr["Sucursal"].ToString());
                fec.Salon = dr["Salon"].ToString();
                fec.Fecha = DateTime.Parse(dr["Fecha"].ToString());
                fec.Confirmada = dr["Confirmado"].ToString().Contains("1") ? true : false;
                result.Add(fec);
            }
            con.Close();
            return result;
        }
        catch (MySqlException e)
        {
            con.Close();
            return null;
        }

    }

0 个答案:

没有答案