How to expose only a few columns of the table in a WebService via SOAP?

0

How can I display only a few columns in a WebService? Home Example:

I need to expose only the Name and AboutName of the table:

public class Cliente 
{
   public string Nome {get; set;}
   public string SobreNome {get; set;}
   public string CPF {get; set;}
}

[WebMethod]
public Cliente RetrieveDevice(Cliente Cliente)
{
    Cliente cli = new Cliente();
    Negocio objNegocio = new Negocio();
    cli = objNegocio.getCliente(Cliente);
    return cli;
}
    
asked by anonymous 04.10.2018 / 21:49

1 answer

1

You can do this by using the [XmlIgnore()] attribute on the property that you do not want to be serialized, in this case the CPF property:

public class Cliente 
{
   public string Nome {get; set;}
   public string SobreNome {get; set;}

   [XmlIgnore()]
   public string CPF {get; set;}
}
    
04.10.2018 / 21:56