Bueno esto parece una tontería. C# no tiene un tipo date, si puedes usar un DateTime, pero no un date.
Teníamos un SW y queríamos que la salida fuera fecha (sin la parte time). Lo cual parece algo sencillo, pero no lo es sobre todo al no tener un tipo DATE
Solución
[XmlSerializerFormat]
Ejemplo :
namespace WcfService1
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[XmlSerializerFormat]
MiTipo FuncionPrueba();
}
public class MiTipo
{
DateTime cumple = DateTime.Now;
[XmlElement(DataType = "date")]
public DateTime cumpleValue
{
get { return
cumple; }
set { cumple = value; }
}
public DateTime Completo
{
get { return cumple; }
set { cumple = value; }
}
}
}
Salida:
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FuncionPruebaResponse
xmlns="http://tempuri.org/">
<FuncionPruebaResult>
<cumpleValue>2015-12-07</cumpleValue>
<Completo>2015-12-07T17:16:17.2141476+01:00</Completo>
</FuncionPruebaResult>
</FuncionPruebaResponse>
</s:Body>
</s:Envelope>
No hay comentarios:
Publicar un comentario