Click here to Skip to main content
15,891,607 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why can't I get any answers to the questions I put. Pin
PIEBALDconsult5-Jun-16 6:14
mvePIEBALDconsult5-Jun-16 6:14 
GeneralRe: Why can't I get any answers to the questions I put. Pin
OriginalGriff5-Jun-16 6:26
mveOriginalGriff5-Jun-16 6:26 
AnswerRe: Why can't I get any answers to the questions I put. Pin
V.5-Jun-16 19:42
professionalV.5-Jun-16 19:42 
GeneralRe: Why can't I get any answers to the questions I put. Pin
OriginalGriff5-Jun-16 20:06
mveOriginalGriff5-Jun-16 20:06 
GeneralRe: Why can't I get any answers to the questions I put. Pin
V.5-Jun-16 20:14
professionalV.5-Jun-16 20:14 
GeneralRe: Why can't I get any answers to the questions I put. Pin
Member 117408556-Jun-16 0:46
Member 117408556-Jun-16 0:46 
GeneralRe: Why can't I get any answers to the questions I put. Pin
Richard MacCutchan6-Jun-16 1:13
mveRichard MacCutchan6-Jun-16 1:13 
QuestionCurrency Converter Pin
Member 108502534-Jun-16 5:50
Member 108502534-Jun-16 5:50 
AnswerRe: Currency Converter Pin
Pete O'Hanlon4-Jun-16 7:15
mvePete O'Hanlon4-Jun-16 7:15 
AnswerRe: Currency Converter Pin
BillWoodruff4-Jun-16 15:42
professionalBillWoodruff4-Jun-16 15:42 
QuestionWhy the tab open I'm not see record, but when i query see record ? Pin
Member 24584673-Jun-16 17:44
Member 24584673-Jun-16 17:44 
AnswerRe: Why the tab open I'm not see record, but when i query see record ? Pin
Gerry Schmitz3-Jun-16 18:20
mveGerry Schmitz3-Jun-16 18:20 
AnswerRe: Why the tab open I'm not see record, but when i query see record ? Pin
OriginalGriff3-Jun-16 19:26
mveOriginalGriff3-Jun-16 19:26 
QuestionProblem with AForge Neuro RunEpoch Pin
Infovl3-Jun-16 14:36
Infovl3-Jun-16 14:36 
SuggestionRe: Problem with AForge Neuro RunEpoch Pin
Matt T Heffron3-Jun-16 16:48
professionalMatt T Heffron3-Jun-16 16:48 
AnswerRe: Problem with AForge Neuro RunEpoch Pin
Pete O'Hanlon3-Jun-16 20:47
mvePete O'Hanlon3-Jun-16 20:47 
AnswerRe: Problem with AForge Neuro RunEpoch Pin
BillWoodruff4-Jun-16 7:36
professionalBillWoodruff4-Jun-16 7:36 
Questionmake BeginInvoke from a form that is invisble Pin
Member 125150673-Jun-16 8:46
Member 125150673-Jun-16 8:46 
AnswerRe: make BeginInvoke from a form that is invisble Pin
Dave Kreskowiak3-Jun-16 12:11
mveDave Kreskowiak3-Jun-16 12:11 
QuestionTrouble downloading results of http request Pin
Member 101734793-Jun-16 6:12
Member 101734793-Jun-16 6:12 
QuestionCannot Get Any Values From A WCF REST Service Pin
MadDashCoder3-Jun-16 5:56
MadDashCoder3-Jun-16 5:56 
My WCF REST service was created in a class library, hosted in a console app, and consumed in a console app.

Please see code below and my point out why both ID and StartTime are empty when I try to retieve them in my client app.

C#
public class Player
{
    public string ID { get; set; }
    public string StartTime { get; set; }
    public string EndTime { get; set; }

    public Player()
    {
       ID = Guid.NewGuid().ToString();
       StartTime = DateTime.Now.ToString();
    }
}

[DataContract]
public class ChessGame
{   [DataMember]
    public List<Player> Players { get; set; }
    [DataMember]
    public string PlayerId { get; set; }

    public Facility()
    {
        Players = new List<Player>();
        PlayerId = string.Empty;
    }

    public void StartGame()
    {
        Player p = new Player();
        PlayerId = p.ID;
        Players.Add(p);
    }
}


C#
public class GameService:IGameService
{
   ChessGame cg = new ChessGame();
    public void StartGame()
   {
      cg.StartGame();
   }
   public string GetPlayerID()
   {
      return cg.PlayerId
   }
   public string GetStartTime(string id)
   {
      return cg.Players.Find(p => p.ID == id).StartTime;
   }
}

 [ServiceContract]
  public interface IGameService
   {
       [WebInvoke(UriTemplate = "Game/", Method = "POST", ResponseFormat = WebMessageFormat.Xml)]
       [OperationContract]
       void StartGame();

       [WebGet(UriTemplate = "ID/", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml)]
       [OperationContract]
       string GetPlayerID();

       [WebGet(UriTemplate = "Time/{id}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml)]
       [OperationContract]
       string GetStartTime(string id);
    }


C#
static void Main(string[] args)
{
  string ID = string.Empty;

  ChannelFactory<IGameService> channelFactory = new ChannelFactory<IGameService>(new WebHttpBinding(), "http://localhost:8080");
  channelFactory.Endpoint.Behaviors.Add(new WebHttpBehavior());

  IGameService channel = channelFactory.CreateChannel();

  channel.StartGame();
  ID = channe.GetPlayerID();
  Console.WriteLine("ID is: {0} ", ID);

  Console.WriteLine("Game started at: {0} ", channe.GetStartTime(ID));

  Console.Read();
}


modified 3-Jun-16 19:38pm.

AnswerRe: Cannot Get Any Values From A WCF REST Service Pin
Gerry Schmitz3-Jun-16 8:28
mveGerry Schmitz3-Jun-16 8:28 
GeneralRe: Cannot Get Any Values From A WCF REST Service Pin
MadDashCoder3-Jun-16 13:32
MadDashCoder3-Jun-16 13:32 
GeneralRe: Cannot Get Any Values From A WCF REST Service Pin
Gerry Schmitz3-Jun-16 19:15
mveGerry Schmitz3-Jun-16 19:15 
QuestionMonitor FTP and SFTP folders through FileSystemWatcher class Pin
amjegan2-Jun-16 21:05
amjegan2-Jun-16 21:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.