Geekpedia Programming Tutorials






WCF Passing Full IList Objects With Empty Properties?

On Friday, October 3rd 2008 at 02:16 PM
By Anonymous
I have a WCF server that passes back instanced objects with null/empty
parameters. Why would this happeN? Source follows:



// Interface

namespace devns.ServiceProviders.TCs
{
[ServiceContract( Name = "IReceiver" , Namespace =
"http://testdom.com/IReceiver" )]
public interface IReceiver
{
[OperationContract]
IList<TC> TCsGetAll();
}
}



// Receiver class, WCF endpoint

namespace devns.ServiceProviders.TCs
{
public class Receiver : IReceiver
{
public IList<TC> TCsGetAll()
{
IList<TC> tclist = new IList<TC>();
TC liveTC = new TC();
liveTC.TCCode = "qqqq";
liveTC.TCDesc = "rrrr";
tclist.Add( liveTC );
return tclist;
}

}
}



// Test class that will be de/serialized

namespace devns.Entities
{
[DataContract(Name="TC")]
public class TC
{
[DataMember]
public int TCId { get; set; }

[DataMember]
public string TCCode { get; set; }
}
}



// Console app. If I set a breakpoint on the last line, the list has one
item but the properties are empty.

namespace WcfCallTemp
{
class Program
{
static void Main( string[] args )
{
ChannelFactory<IReceiver> TCProxy = new ChannelFactory<IReceiver>(
"WcfTCsReceiver" );
TCProxy.Open();
IReceiver TCReceiver = TCProxy.CreateChannel();
IList<TC> localTCs = TCReceiver.TCsGetAll();
TCProxy.Close();
Console.ReadLine();
}
}
}

RE: WCF Passing Full IList Objects with Empty Properties?

by Anonymous on Friday, October 3rd 2008 at 04:50 PM
I think there is something wrong with my TC class. I added a method to the
service to return a simple string and the string is visible in the console
app client. I added .dll file references to the compiled assembly that
contains the stuff from the wcf service as well as the assembly that contains
the TC class.

Help!


"coconet" wrote:

>
>
> I have a WCF server that passes back instanced objects with null/empty
> parameters. Why would this happeN? Source follows:
>
>
>
> // Interface
>
> namespace devns.ServiceProviders.TCs
> {
> [ServiceContract( Name = "IReceiver" , Namespace =
> "http://testdom.com/IReceiver" )]
> public interface IReceiver
> {
> [OperationContract]
> IList<TC> TCsGetAll();
> }
> }
>
>
>
> // Receiver class, WCF endpoint
>
> namespace devns.ServiceProviders.TCs
> {
> public class Receiver : IReceiver
> {
> public IList<TC> TCsGetAll()
> {
> IList<TC> tclist = new IList<TC>();
> TC liveTC = new TC();
> liveTC.TCCode = "qqqq";
> liveTC.TCDesc = "rrrr";
> tclist.Add( liveTC );
> return tclist;
> }
>
> }
> }
>
>
>
> // Test class that will be de/serialized
>
> namespace devns.Entities
> {
> [DataContract(Name="TC")]
> public class TC
> {
> [DataMember]
> public int TCId { get; set; }
>
> [DataMember]
> public string TCCode { get; set; }
> }
> }
>
>
>
> // Console app. If I set a breakpoint on the last line, the list has one
> item but the properties are empty.
>
> namespace WcfCallTemp
> {
> class Program
> {
> static void Main( string[] args )
> {
> ChannelFactory<IReceiver> TCProxy = new ChannelFactory<IReceiver>(
> "WcfTCsReceiver" );
> TCProxy.Open();
> IReceiver TCReceiver = TCProxy.CreateChannel();
> IList<TC> localTCs = TCReceiver.TCsGetAll();
> TCProxy.Close();
> Console.ReadLine();
> }
> }
> }
>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons