Moose Pickard

Moose Pickard

  • NA
  • 64
  • 69.6k

Problem with consuming WCF data in Windows Forms Application

Apr 30 2012 6:47 AM
I'm new to WCF. So here are my problems:
I have a problem accessing WCF data from forms application.

My example class
    [DataContract]
    public class City
    {
        #region fields
        [DataMember]
        private int _id;
        [DataMember]
        private string _name;
        #endregion


        public City(int id, string name)
        {
            this._id = id;
            this._name = name;
        }
    }

I have some method which returns this object:

public static City[] displayCitys(){
//Some code, but it returns an array of City's
}


Now i connect my service with a Windows Forms Application and try to run the function:

            ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
            client.displayCitys();


How could I access data from this function?
Since it returns a object type City I can't access it, in my forms application which doesn't have this class definition.
Even if I created it it said they are not the same.
Should I rewrite the function to return some simpler types such as array of strings etc?

I also wonder if I'd access this function from PHP would I have the same problem?




Thanks in advance









































Answers (2)