Skip to content

Instantly share code, notes, and snippets.

@codingarchitect
Created January 24, 2017 10:57
Show Gist options
  • Save codingarchitect/1527cb899f35e935e0efc00705ebc20e to your computer and use it in GitHub Desktop.
Save codingarchitect/1527cb899f35e935e0efc00705ebc20e to your computer and use it in GitHub Desktop.
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.ServiceModel.dll</Reference>
<Namespace>System.ServiceModel</Namespace>
</Query>
void Main()
{
CallService();
}
public static void CallService()
{
try
{
var address = new EndpointAddress("http://localhost:9999/WindsorWcfServiceApp/GreeterService.svc");
var binding = new BasicHttpBinding();
var channelFactory = new ChannelFactory<CodingArchitect.Spikes.WindsorWcfService.IGreeterService>(binding, address);
CodingArchitect.Spikes.WindsorWcfService.IGreeterService greeterClient = channelFactory.CreateChannel();
((IContextChannel)greeterClient).OperationTimeout = new TimeSpan(0, 0, 45);
string result = greeterClient.Greet();
string.Format("Recieved Service Result....{0}", result).Dump();
((IClientChannel)greeterClient).Close();
}
catch(Exception ex)
{
string.Format("Recieved Exception....{0}", ex.Message).Dump();
}
}
} // Shut linqpad up for namespace declarations
#region Service Classes
namespace CodingArchitect.Spikes.WindsorWcfService
{
using System.ServiceModel;
[ServiceContract]
public interface IGreeterService
{
[OperationContract]
string Greet();
}
}
#endregion
// Shut linqpad up for namespace declarations
class EOF {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment