|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Xml;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Transactions;
namespace ClientApplication
{
[XmlSerializerFormat]
[DataContract(Name = "Request", Namespace = "urn:workflowinvoker.test")]
public class Request
{
[DataMember]
private int counter;
public int Counter
{
get { return counter; }
set { counter = value; }
}
[DataMember]
private string text;
public string Text
{
get { return text; }
set { text = value; }
}
[DataMember]
private DateTime timestamp;
public DateTime Timestamp
{
get { return timestamp; }
set { timestamp = value; }
}
}
[ServiceContract]
public interface IPing
{
[OperationContract(Action = "Ping")]
string Ping(Request request);
[OperationContract(Action = "Ping2")]
string Ping2(Request request);
}
class Program
{
static void Main(string[] args)
{
try
{
for (int ii = 0; ii < 100; ii++)
{
using (ChannelFactory<IPing> pingChannel = new ChannelFactory<IPing>("Pinging"))
{
pingChannel.Open();
IPing ping = pingChannel.CreateChannel();
Request request = new Request();
request.Counter = ii;
request.Text = "This si a loopback message";
request.Timestamp = DateTime.Now;
string response = ping.Ping(request);
Console.WriteLine(response);
// test 2
Console.WriteLine("\nPing2 test:");
string response2 = ping.Ping2(request);
Console.WriteLine(response);
pingChannel.Close();
Console.WriteLine("\nDone, Press any key to test again");
Console.ReadLine();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Console.ReadLine();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.