Skip to content

Instantly share code, notes, and snippets.

@codingarchitect
Created January 18, 2017 08:54
Show Gist options
  • Select an option

  • Save codingarchitect/9f9e32f679fc0327820fbe817a0afaf6 to your computer and use it in GitHub Desktop.

Select an option

Save codingarchitect/9f9e32f679fc0327820fbe817a0afaf6 to your computer and use it in GitHub Desktop.
Create a web service (App Pool, Web Site, Web Application in IIS), Compiles the code to a separate assembly, Gives permissions to the app pool identity to the web service folder.
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\Microsoft.CSharp.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.InteropServices.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.InteropServices.WindowsRuntime.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.Serialization.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.ServiceModel.dll</Reference>
<NuGetReference>Microsoft.Web.Administration</NuGetReference>
<NuGetReference>NUnitLite</NuGetReference>
<NuGetReference>CodingArchitect.Utilities</NuGetReference>
<Namespace>Microsoft.CSharp</Namespace>
<Namespace>Microsoft.CSharp.RuntimeBinder</Namespace>
<Namespace>Microsoft.Web.Administration</Namespace>
<Namespace>NUnit.Framework</Namespace>
<Namespace>NUnitLite</Namespace>
<Namespace>System.CodeDom.Compiler</Namespace>
<Namespace>System.Runtime.InteropServices</Namespace>
</Query>
void Main()
{
var queryDirectory = Path.GetDirectoryName(Util.CurrentQueryPath);
Environment.CurrentDirectory = queryDirectory;
var companyName = "CodingArchitect";
var serviceWebsitetName = "WebServiceUsingLinqpad";
var port = "9898";
var webServiceTypeName = "GreeterService";
CodingArchitect.Utilities.Linqpad.Util.SetupWebService(companyName, serviceWebsitetName, port, webServiceTypeName, queryDirectory, Util.CurrentQueryPath);
}
// Define other methods and classes here
}
#region Service Classes
namespace CodingArchitect.Spikes.WebServiceUsingLinqpad
{
using System.ServiceModel;
public class GreeterService : IGreeterService
{
public string Greet()
{
// Simulate I/O
Thread.Sleep(1000);
return "Hello World from Web Service";
}
}
[ServiceContract]
public interface IGreeterService
{
[OperationContract]
string Greet();
}
}
#endregion
class EOF {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment