Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DinisCruz/9878271 to your computer and use it in GitHub Desktop.
Save DinisCruz/9878271 to your computer and use it in GitHub Desktop.
C# scripts used on blog post: 'Programmatically configuring an WCF service without using .config files (using FluentSharp REPL)'
return service1Client.GetData(42);
//O2Ref:WCF_Consumer.exe
//O2Ref:System.ServiceModel.dll
var composite = new CompositeType
{
StringValue = "Hello ",
BoolValue = true
};
return service1Client.GetDataUsingDataContract(composite);
//using WCF_Consumer.ServiceReference1
//O2Ref:WCF_Consumer.exe
//O2Ref:System.ServiceModel.dll
//O2Ref:System.Runtime.Serialization.dll
var myBinding = new WSHttpBinding();
var url = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/";
var endpointAddress = new EndpointAddress(url);
var serviceClient = new Service1Client(myBinding,endpointAddress);
compositeType.StringValue = "Hello";
return serviceClient.GetDataUsingDataContract(compositeType);
//using System.ServiceModel
//using WCF_Consumer.ServiceReference1
//O2Ref:WCF_Consumer.exe
//O2Ref:System.ServiceModel.dll
//O2Ref:System.Runtime.Serialization.dll
Func<Service1Client> getServiceClient =
()=>{
var url = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/";
var myBinding = new WSHttpBinding();
var endpointAddress = new EndpointAddress(url);
return new Service1Client(myBinding,endpointAddress);
};
Func<string, bool,CompositeType> sendAndReceive =
(stringValue, boolValue)=>{
var serviceClient = getServiceClient();
compositeType.StringValue = stringValue;
compositeType.BoolValue = boolValue;
return serviceClient.GetDataUsingDataContract(compositeType);
};
return sendAndReceive("a Value ", true);
//using System.ServiceModel
//using WCF_Consumer.ServiceReference1
//O2Ref:WCF_Consumer.exe
//O2Ref:System.ServiceModel.dll
//O2Ref:System.Runtime.Serialization.dll
var topPanel = "Example of WCF client call".popupWindow(250,100);
//var topPanel = panel.clear().add_Panel();
var textBox = topPanel.add_TextBox(true);
var myBinding = new WSHttpBinding();
var url = "http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/";
var endpointAddress = new EndpointAddress(url);
var serviceClient = new Service1Client(myBinding,endpointAddress);
var compositeType = new CompositeType { StringValue = "Hello from C# ",
BoolValue = true };
var returnValue = serviceClient.GetDataUsingDataContract(compositeType);
textBox.set_Text(returnValue.StringValue);
return returnValue;
//using System.ServiceModel
//using WCF_Consumer.ServiceReference1
//O2Ref:WCF_Consumer.exe
//O2Ref:System.ServiceModel.dll
//O2Ref:System.Runtime.Serialization
//O2File:c:\users\o2\documents\visual studio 2010\Projects\WCF_Consumer\Service References\ServiceReference1\Reference.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment