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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace WcfSampleServer | |
{ | |
[System.ServiceModel.ServiceContract] | |
public interface IHelloWorldService | |
{ | |
[System.ServiceModel.OperationContract] | |
void Hello(); | |
} | |
public class HelloWorldService : IHelloWorldService | |
{ | |
public void Hello() | |
{ | |
System.Console.WriteLine("Hello, World"); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(HelloWorldService))) | |
{ | |
host.AddServiceEndpoint(typeof(IHelloWorldService), | |
new System.ServiceModel.NetNamedPipeBinding(), | |
"net.pipe://localhost/HelloWorld"); | |
host.Open(); | |
System.Console.WriteLine("Started host."); | |
System.Console.ReadLine(); | |
host.Close(); | |
} | |
} | |
} | |
} |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using WcfSampleServer; | |
namespace WcfSampleClient | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var channelFactory = new System.ServiceModel.ChannelFactory<IHelloWorldService>( | |
new System.ServiceModel.NetNamedPipeBinding(), | |
new System.ServiceModel.EndpointAddress("net.pipe://localhost/HelloWorld")); | |
channelFactory.Open(); | |
IHelloWorldService proxy = channelFactory.CreateChannel(); | |
proxy.Hello(); | |
channelFactory.Close(); | |
} | |
} | |
} |
0 件のコメント:
コメントを投稿