Created
January 24, 2017 10:57
-
-
Save codingarchitect/1527cb899f35e935e0efc00705ebc20e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query Kind="Program"> | |
<Reference><RuntimeDirectory>\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