service side

1.定义ServiceContract:

2.new a ServiceHost

3. add endpoint

using System.ServiceModel;

namespace Service
{
class Program
{
static void Main(string[] args)
{
Uri address = new Uri("http://localhost:8000/myservice");
using (ServiceHost host = new ServiceHost(typeof(MyService), address))      //MyService是服务方法的类库名称
{
host.AddServiceEndpoint(typeof(IMyService), new BasicHttpBinding(), address); //IMyService是服务接口类库名称
host.Open();
Console.ReadLine();
}
} } [ServiceContract]
public interface IMyService
{
[OperationContract]
string GetService();
} public class MyService : IMyService
{ public string GetService()
{
return "Got Service!";
}
}
}

client side: get proxy, service 调用

using System.ServiceModel;

namespace Client
{
class Program
{
static void Main(string[] args)
{
IMyService proxy = ChannelFactory<IMyService>.CreateChannel(new BasicHttpBinding(),
new EndpointAddress("http://localhost:8000/myservice"));
Console.WriteLine(proxy.GetService());
Console.ReadLine();
}
} [ServiceContract]
public interface IMyService
{
[OperationContract]
string GetService();
} }

bdc = new BaseDataClient(new BasicHttpBinding(), new EndpointAddress(Configurator.GetConfigValue("stsurl")));
    <add key="stsurl" value="http://192.168.100.1:8888/CoreData.svc" />

最新文章

  1. 关于从Activity A跳转到Activity B ,其中Activity A中有一个VideoView,Activity B中有一个MediaPlayer。
  2. Linux文件类型
  3. mysql环境搭建
  4. Android自定义控件(二)
  5. Android应用中使用AsyncHttpClient来异步网络数据(转载)
  6. JSP中的Servlet及Filter
  7. LPCTSTR 用法
  8. 【转载】jQuery1.5之后的deferred对象详解
  9. WPF用ShowDialog()弹出窗体时控制该窗体的显示位置,并传值回父窗体
  10. CSS3之firefox&amp;safari背景渐变之争 - [前端技术][转]
  11. How do I list all tables/indices contained in an SQLite database
  12. Android studio中Rendering Problems不能可视化操作的解决办法
  13. linux的fork函数
  14. nginx的autoindex-目录浏览还有其它两个参数
  15. Java数据结构漫谈-Vector
  16. 我推荐的一些iOS开发书单
  17. Python基础---python中的异常处理
  18. Python学习之dict和set
  19. less--入门
  20. 学习笔记:fhq-treap

热门文章

  1. (小规模)b牌棋盘完美覆盖数
  2. Linux下KVM虚拟机基本管理及常用命令(转)
  3. JavaScript里的循环方法:forEach,for-in,for-of
  4. iOS 捕获程序崩溃日志
  5. ashx 下载文件
  6. sqlmap原理及使用方法
  7. 爬虫之多线程 多进程 自定义异步IO框架
  8. enter 键登录的实现
  9. RDD原理与详解
  10. DataGridView绑定泛型List时,利用BindingList来实现增删查改