http://blog.csdn.net/suntanyong88/article/details/8203572

 
 

图1

1,OrderTrack.Windows.KZT  : 控制台应用 程序,用于调试 wcf服务端 接口问题,

2,OrderTrack.Windows.Service :  windows服务,可以发布到服务端,

怎么创建 windows 服务 ,可以参考   链接地址  wcf服务注册windows服务

3,FluentAdo.SqlServer   数据源适合wcf服务的那种调用方式,跟常用的调用sqlhelp 有很大区别。

4,WcfWebApplication   展示 客户端调用,

5,其它的 类库 分别 是  接口,实现,实体。

1,展示下 控制台应用程序配置

web.config配置

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3. <configSections>
  4. </configSections>
  5. <appSettings>
  6. <add key="Travel"  value="Data Source=服务器名;Initial Catalog=xxx;User ID=帐号;Password=密码;Asynchronous Processing=True;MultipleActiveResultSets=True"/>
  7. <add key="OrderTrackRouter"  value="Data Source=服务器名;Initial Catalog=数据库名;User ID=帐号;Password=密码"/>
  8. </appSettings>
  9. <connectionStrings>
  10. </connectionStrings>
  11. <system.serviceModel>
  12. <behaviors>
  13. <serviceBehaviors>
  14. <behavior name="Wcf.MyBehaviorConfiguration">
  15. <serviceMetadata httpGetEnabled="false" />
  16. <serviceDebug includeExceptionDetailInFaults="false" />
  17. <dataContractSerializer maxItemsInObjectGraph="2147483647" />
  18. </behavior>
  19. </serviceBehaviors>
  20. </behaviors>
  21. <bindings>
  22. <!-- wcf协议 -->
  23. <netTcpBinding>
  24. <binding name="netTcpBinding_Mybinding"
  25. closeTimeout="00:10:00"
  26. openTimeout="00:10:00"
  27. receiveTimeout="00:10:00"
  28. sendTimeout="00:10:00"
  29. transactionFlow="false"
  30. transferMode="Buffered"
  31. transactionProtocol="OleTransactions"
  32. hostNameComparisonMode="StrongWildcard"
  33. listenBacklog="10"
  34. maxBufferPoolSize="2147483647 "
  35. maxBufferSize="2147483647 "
  36. maxConnections="10"
  37. maxReceivedMessageSize="2147483647 ">
  38. <readerQuotas maxDepth="64" maxStringContentLength="2147483647 " maxArrayLength="2147483647 " maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  39. <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
  40. <security mode="None"></security>
  41. </binding>
  42. </netTcpBinding>
  43. </bindings>
  44. <services>
  45. <!--订单跟踪 -->
  46. <service name="OrderTrack.DAL.OrderTrackRouter_Service">
  47. <endpoint  address="net.tcp://127.0.0.1:6438/OrderTrack.DAL.OrderTrackRouter_Service"
  48. contract="OrderTrack.Interface.OrderTrackRouter_IService"
  49. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding"  />
  50. </service>
  51. <!-- RTX跟踪 -->
  52. <service name="OrderTrack.DAL.RTXhistoryDAL">
  53. <endpoint  address="net.tcp://127.0.0.1:5789/OrderTrack.DAL.RTXhistoryDAL"
  54. contract="OrderTrack.Interface.IRTXhistoryDAL"
  55. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding"  />
  56. </service>
  57. </services>
  58. <client>
  59. </system.serviceModel>
  60. </configuration>
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <configuration>
  3. <configSections>
  4. </configSections>
  5. <appSettings>
  6. <add key="Travel" value="Data Source=服务器名;Initial Catalog=xxx;User ID=帐号;Password=密码;Asynchronous Processing=True;MultipleActiveResultSets=True"/>
  7. <add key="OrderTrackRouter" value="Data Source=服务器名;Initial Catalog=数据库名;User ID=帐号;Password=密码"/>
  8. </appSettings>
  9. <connectionStrings>
  10. </connectionStrings>
  11. <system.serviceModel>
  12. <behaviors>
  13. <serviceBehaviors>
  14. <behavior name="Wcf.MyBehaviorConfiguration">
  15. <serviceMetadata httpGetEnabled="false" />
  16. <serviceDebug includeExceptionDetailInFaults="false" />
  17. <dataContractSerializer maxItemsInObjectGraph="2147483647" />
  18. </behavior>
  19. </serviceBehaviors>
  20. </behaviors>
  21. <bindings>
  22.  
  23. <!-- wcf协议 -->
  24. <netTcpBinding>
  25. <binding name="netTcpBinding_Mybinding"
  26. closeTimeout="00:10:00"
  27. openTimeout="00:10:00"
  28. receiveTimeout="00:10:00"
  29. sendTimeout="00:10:00"
  30. transactionFlow="false"
  31. transferMode="Buffered"
  32. transactionProtocol="OleTransactions"
  33. hostNameComparisonMode="StrongWildcard"
  34. listenBacklog="10"
  35. maxBufferPoolSize="2147483647 "
  36. maxBufferSize="2147483647 "
  37. maxConnections="10"
  38. maxReceivedMessageSize="2147483647 ">
  39. <readerQuotas maxDepth="64" maxStringContentLength="2147483647 " maxArrayLength="2147483647 " maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  40. <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
  41. <security mode="None"></security>
  42. </binding>
  43. </netTcpBinding>
  44. </bindings>
  45.  
  46. <services>
  47. <!--订单跟踪 -->
  48. <service name="OrderTrack.DAL.OrderTrackRouter_Service">
  49. <endpoint address="net.tcp://127.0.0.1:6438/OrderTrack.DAL.OrderTrackRouter_Service"
  50. contract="OrderTrack.Interface.OrderTrackRouter_IService"
  51.  
  52. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding" />
  53. </service>
  54.  
  55. <!-- RTX跟踪 -->
  56. <service name="OrderTrack.DAL.RTXhistoryDAL">
  57. <endpoint address="net.tcp://127.0.0.1:5789/OrderTrack.DAL.RTXhistoryDAL"
  58. contract="OrderTrack.Interface.IRTXhistoryDAL"
  59. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding" />
  60. </service>
  61. </services>
  62.  
  63. <client>
  64.  
  65. </system.serviceModel>
  66. </configuration>

注意事项:  1,wcf协议可以共用一个

2,tcp服务端口部署到服务器,端口号不能重复重复之后,windows服务启动不了,会产生错误日志。出现服务启用不了,

                    修改 端口号,除了这个原因,还有别的原因也会导致服务启动不了。可以到事件查看器 查看对应错误,如:图2

  右键点击错误日志属性查看错误

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ServiceModel;
  6. using OrderTrack.DAL;
  7. /*
  8. 创建人 谈勇 2012-11-7
  9. */
  10. namespace OrderTrack.Windows.Service.WCFService
  11. {
  12. internal class RtxStartService
  13. {
  14. /// <summary>
  15. /// 创建服务主机对象
  16. /// </summary>
  17. internal static ServiceHost serviceHost = null;
  18. /// <summary>
  19. /// 启动服务函数
  20. /// </summary>
  21. internal static void StartService()
  22. {
  23. if (serviceHost != null)
  24. {
  25. serviceHost.Close();
  26. }
  27. serviceHost = new ServiceHost(typeof(RTXhistoryDAL));
  28. serviceHost.Open();
  29. }
  30. /// <summary>
  31. /// 停止服务
  32. /// </summary>
  33. internal static void StopService()
  34. {
  35. if (serviceHost != null)
  36. {
  37. serviceHost.Close();
  38. serviceHost = null;
  39. }
  40. }
  41. }
  42. }
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ServiceModel;
  6. using OrderTrack.DAL;
  7.  
  8. /*
  9. 创建人 谈勇 2012-11-7
  10. */
  11. namespace OrderTrack.Windows.Service.WCFService
  12. {
  13. internal class RtxStartService
  14. {
  15. /// <summary>
  16. /// 创建服务主机对象
  17. /// </summary>
  18. internal static ServiceHost serviceHost = null;
  19.  
  20. /// <summary>
  21. /// 启动服务函数
  22. /// </summary>
  23. internal static void StartService()
  24. {
  25. if (serviceHost != null)
  26. {
  27. serviceHost.Close();
  28. }
  29. serviceHost = new ServiceHost(typeof(RTXhistoryDAL));
  30. serviceHost.Open();
  31. }
  32.  
  33. /// <summary>
  34. /// 停止服务
  35. /// </summary>
  36. internal static void StopService()
  37. {
  38. if (serviceHost != null)
  39. {
  40. serviceHost.Close();
  41. serviceHost = null;
  42. }
  43. }
  44. }
  45. }
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.ServiceProcess;
  8. using System.Text;
  9. using OrderTrack.Windows.KZT.WCFService;
  10. namespace OrderTrack.Windows.KZT
  11. {
  12. partial class WindowsService : ServiceBase
  13. {
  14. /// <summary>
  15. /// 服务名称
  16. /// </summary>
  17. internal const string SERVICE_NAME = "WCFServiceHost";
  18. protected static void WCFServiceHost_Start()
  19. {
  20. //订单跟踪服务启动
  21. OrderTrackRouter_WCFService.StartService();
  22. //rtx 服务启动
  23. RtxStartService.StartService();
  24. }
  25. protected static void WCFServiceHost_Stop()
  26. {
  27. //调用服务停止函数
  28. // WhetherStartService.StopService();
  29. //rtx 服务关闭
  30. //RtxStartService.StopService();
  31. }
  32. public WindowsService()
  33. {
  34. //InitializeComponent();
  35. ServiceName = SERVICE_NAME;
  36. }
  37. protected override void OnStart(string[] args)
  38. {
  39. // TODO: 在此处添加代码以启动服务。
  40. WCFServiceHost_Start();
  41. }
  42. protected override void OnStop()
  43. {
  44. // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
  45. WCFServiceHost_Stop();
  46. }
  47. private static void RunAsConsole()
  48. {
  49. ///添加控制台TITLE
  50. Console.Title = "我的地盘听我的";
  51. WCFServiceHost_Start();
  52. Console.ReadKey();  //不做控制台程序可以 修改成 Consolse.Read();
  53. }
  54. private static void RunAsService()
  55. {
  56. //Run(new WindowsService());
  57. ServiceBase[] ServicesToRun;
  58. ServicesToRun = new ServiceBase[]
  59. {
  60. new WindowsService()
  61. };
  62. ServiceBase.Run(ServicesToRun);
  63. }
  64. public static void Main()
  65. {
  66. if (Environment.UserInteractive)
  67. {
  68. RunAsConsole();
  69. }
  70. else
  71. {
  72. RunAsService();
  73. }
  74. }
  75. }
  76. }
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.ServiceProcess;
  8. using System.Text;
  9. using OrderTrack.Windows.KZT.WCFService;
  10.  
  11. namespace OrderTrack.Windows.KZT
  12. {
  13. partial class WindowsService : ServiceBase
  14. {
  15. /// <summary>
  16. /// 服务名称
  17. /// </summary>
  18. internal const string SERVICE_NAME = "WCFServiceHost";
  19.  
  20. protected static void WCFServiceHost_Start()
  21. {
  22. //订单跟踪服务启动
  23. OrderTrackRouter_WCFService.StartService();
  24. //rtx 服务启动
  25. RtxStartService.StartService();
  26. }
  27.  
  28. protected static void WCFServiceHost_Stop()
  29. {
  30. //调用服务停止函数
  31. // WhetherStartService.StopService();
  32. //rtx 服务关闭
  33. //RtxStartService.StopService();
  34.  
  35. }
  36.  
  37. public WindowsService()
  38. {
  39. //InitializeComponent();
  40.  
  41. ServiceName = SERVICE_NAME;
  42. }
  43.  
  44. protected override void OnStart(string[] args)
  45. {
  46. // TODO: 在此处添加代码以启动服务。
  47. WCFServiceHost_Start();
  48. }
  49.  
  50. protected override void OnStop()
  51. {
  52. // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
  53. WCFServiceHost_Stop();
  54. }
  55.  
  56. private static void RunAsConsole()
  57. {
  58. ///添加控制台TITLE
  59. Console.Title = "我的地盘听我的";
  60. WCFServiceHost_Start();
  61. Console.ReadKey(); //不做控制台程序可以 修改成 Consolse.Read();
  62. }
  63.  
  64. private static void RunAsService()
  65. {
  66. //Run(new WindowsService());
  67.  
  68. ServiceBase[] ServicesToRun;
  69. ServicesToRun = new ServiceBase[]
  70. {
  71. new WindowsService()
  72. };
  73. ServiceBase.Run(ServicesToRun);
  74. }
  75.  
  76. public static void Main()
  77. {
  78. if (Environment.UserInteractive)
  79. {
  80. RunAsConsole();
  81. }
  82. else
  83. {
  84. RunAsService();
  85. }
  86.  
  87. }
  88. }
  89. }

图3, 服务配置

图4 ,wcf接口的实现

<!-- RTX跟踪 -->       <service name="OrderTrack.DAL.RTXhistoryDAL">         <endpoint  address="net.tcp://127.0.0.1:5789/OrderTrack.DAL.RTXhistoryDAL"                   contract="OrderTrack.Interface.IRTXhistoryDAL"                     binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding"  />       </service>

  注意看图 4 和 协议的配置 是有关联的。

总结一下,wcf配置一定要细心,监听和协议有一点不一样,那个客户端 调用 服务器 接口 是 ping 不通的。

5. 展示客户端调用

要下载个 wcf插件

ACorns.WCF.DynamicClientProxy   文件  可以用一个专门的类型去封装 那个 wcf插件文件包

客户端引用 只要拿 那个 dll文件就行。

总结:编写wcf接口服务 调用 设计的越简单越好,这样别人拿到你的接口 ,引用几个 dll文件。就能实现你接口的方法 完成对应功能。

客户端的web配置

  1. <?xml version="1.0"?>
  2. <!--
  3. 有关如何配置 ASP.NET 应用程序的详细信息,请访问
  4. http://go.microsoft.com/fwlink/?LinkId=169433
  5. -->
  6. <configuration>
  7. <connectionStrings />
  8. <system.web>
  9. <compilation debug="true" targetFramework="4.0" />
  10. <authentication mode="Forms">
  11. <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
  12. </authentication>
  13. <membership>
  14. <providers>
  15. <clear/>
  16. <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
  17. enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
  18. maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
  19. applicationName="/" />
  20. </providers>
  21. </membership>
  22. <profile>
  23. <providers>
  24. <clear/>
  25. <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
  26. </providers>
  27. </profile>
  28. <roleManager enabled="false">
  29. <providers>
  30. <clear/>
  31. <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
  32. <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
  33. </providers>
  34. </roleManager>
  35. </system.web>
  36. <system.webServer>
  37. <modules runAllManagedModulesForAllRequests="true"/>
  38. </system.webServer>
  39. <!-- wcf 配置 begin-->
  40. <system.serviceModel>
  41. <bindings>
  42. <netTcpBinding>
  43. <binding name="netTcpBinding_Mybinding"
  44. closeTimeout="00:10:00"
  45. openTimeout="00:10:00"
  46. receiveTimeout="00:10:00"
  47. sendTimeout="00:10:00"
  48. transactionFlow="false"
  49. transferMode="Buffered"
  50. transactionProtocol="OleTransactions"
  51. hostNameComparisonMode="StrongWildcard"
  52. listenBacklog="10"
  53. maxBufferPoolSize="2147483647 "
  54. maxBufferSize="2147483647 "
  55. maxConnections="10"
  56. maxReceivedMessageSize="2147483647 ">
  57. <readerQuotas maxDepth="64" maxStringContentLength="2147483647 " maxArrayLength="2147483647 " maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  58. <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
  59. <security mode="None"></security>
  60. </binding>
  61. </netTcpBinding>
  62. </bindings>
  63. <client>
  64. <!-- 订单跟踪 -->
  65. <endpoint  address="net.tcp://127.0.0.1:6438/OrderTrack.DAL.OrderTrackRouter_Service" contract="OrderTrack.Interface.OrderTrackRouter_IService"
  66. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding" name="orderTrack"/>
  67. <!-- RTX跟踪 -->
  68. <endpoint  address="net.tcp://127.0.0.1:5789/OrderTrack.DAL.RTXhistoryDAL" contract="OrderTrack.Interface.IRTXhistoryDAL"
  69. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding" name="rtxTrack"/>
  70. </client>
  71. </system.serviceModel>
  72. <!-- wcf 配置  end-->
  73. </configuration>
  1. <?xml version="1.0"?>
  2.  
  3. <!--
  4. 有关如何配置 ASP.NET 应用程序的详细信息,请访问
  5. http://go.microsoft.com/fwlink/?LinkId=169433
  6. -->
  7.  
  8. <configuration>
  9. <connectionStrings />
  10.  
  11. <system.web>
  12. <compilation debug="true" targetFramework="4.0" />
  13.  
  14. <authentication mode="Forms">
  15. <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
  16. </authentication>
  17.  
  18. <membership>
  19. <providers>
  20. <clear/>
  21. <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
  22. enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
  23. maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
  24. applicationName="/" />
  25. </providers>
  26. </membership>
  27.  
  28. <profile>
  29. <providers>
  30. <clear/>
  31. <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
  32. </providers>
  33. </profile>
  34.  
  35. <roleManager enabled="false">
  36. <providers>
  37. <clear/>
  38. <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
  39. <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
  40. </providers>
  41. </roleManager>
  42.  
  43. </system.web>
  44.  
  45. <system.webServer>
  46. <modules runAllManagedModulesForAllRequests="true"/>
  47. </system.webServer>
  48.  
  49. <!-- wcf 配置 begin-->
  50. <system.serviceModel>
  51. <bindings>
  52. <netTcpBinding>
  53. <binding name="netTcpBinding_Mybinding"
  54. closeTimeout="00:10:00"
  55. openTimeout="00:10:00"
  56. receiveTimeout="00:10:00"
  57. sendTimeout="00:10:00"
  58. transactionFlow="false"
  59. transferMode="Buffered"
  60. transactionProtocol="OleTransactions"
  61. hostNameComparisonMode="StrongWildcard"
  62. listenBacklog="10"
  63. maxBufferPoolSize="2147483647 "
  64. maxBufferSize="2147483647 "
  65. maxConnections="10"
  66. maxReceivedMessageSize="2147483647 ">
  67. <readerQuotas maxDepth="64" maxStringContentLength="2147483647 " maxArrayLength="2147483647 " maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  68. <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
  69. <security mode="None"></security>
  70. </binding>
  71.  
  72. </netTcpBinding>
  73. </bindings>
  74.  
  75. <client>
  76. <!-- 订单跟踪 -->
  77. <endpoint address="net.tcp://127.0.0.1:6438/OrderTrack.DAL.OrderTrackRouter_Service" contract="OrderTrack.Interface.OrderTrackRouter_IService"
  78. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding" name="orderTrack"/>
  79. <!-- RTX跟踪 -->
  80. <endpoint address="net.tcp://127.0.0.1:5789/OrderTrack.DAL.RTXhistoryDAL" contract="OrderTrack.Interface.IRTXhistoryDAL"
  81. binding="netTcpBinding" bindingConfiguration="netTcpBinding_Mybinding" name="rtxTrack"/>
  82. </client>
  83. </system.serviceModel>
  84.  
  85. <!-- wcf 配置 end-->
  86. </configuration>

客户端后台调用 展示 追加RTX记录方法

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using Uzai.OrderTrack.Interface;
  8. using ACorns.WCF.DynamicClientProxy;
  9. using OrderTrack.DataEntities;
  10. namespace WcfWebApplication
  11. {
  12. public partial class RTXTrackTest : System.Web.UI.Page
  13. {
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. RTXWcfNetTcp();
  17. }
  18. public void RTXWcfNetTcp()
  19. {
  20. IRTXhistoryDAL iwt = WCFClientProxy<IRTXhistoryDAL>.GetReusableFaultUnwrappingInstance("rtxTrack");
  21. RTXhistory model = new RTXhistory();
  22. model.orderType = TrackOrderEnum.MeteradJustable;
  23. model.objorderModel.ordercode = "N23151234";
  24. model.objorderModel.dateofDeparture = DateTime.Now;
  25. model.objorderModel.Person = 2;
  26. model.objorderModel.Child = 1;
  27. model.objorderModel.productId = 4788;
  28. model.objorderModel.productName = "菲律宾一日游";
  29. model.objorderModel.prodcutPrice = 4888.88m;
  30. model.objorderModel.OPAdminID = "581";
  31. model.objorderModel.OPAdmin = "tanyong";
  32. model.objorderModel.JDAdminID = "581";
  33. model.objorderModel.JDAdmin = "tanyong";
  34. string strResult = iwt.addRtxHostory(model);
  35. Response.Write(strResult);
  36. }
  37. }
  38. }
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using Uzai.OrderTrack.Interface;
  8. using ACorns.WCF.DynamicClientProxy;
  9. using OrderTrack.DataEntities;
  10.  
  11. namespace WcfWebApplication
  12. {
  13. public partial class RTXTrackTest : System.Web.UI.Page
  14. {
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. RTXWcfNetTcp();
  18. }
  19.  
  20. public void RTXWcfNetTcp()
  21. {
  22.  IRTXhistoryDAL iwt = WCFClientProxy<IRTXhistoryDAL>.GetReusableFaultUnwrappingInstance("rtxTrack");
  23.  
  24. RTXhistory model = new RTXhistory();
  25.  
  26. model.orderType = TrackOrderEnum.MeteradJustable;
  27.  
  28. model.objorderModel.ordercode = "N23151234";
  29. model.objorderModel.dateofDeparture = DateTime.Now;
  30.  
  31. model.objorderModel.Person = 2;
  32. model.objorderModel.Child = 1;
  33.  
  34. model.objorderModel.productId = 4788;
  35. model.objorderModel.productName = "菲律宾一日游";
  36. model.objorderModel.prodcutPrice = 4888.88m;
  37. model.objorderModel.OPAdminID = "581";
  38. model.objorderModel.OPAdmin = "tanyong";
  39. model.objorderModel.JDAdminID = "581";
  40. model.objorderModel.JDAdmin = "tanyong";
  41.  
  42. string strResult = iwt.addRtxHostory(model);
  43.  
  44. Response.Write(strResult);
  45.  
  46. }
  47.  
  48. }
  49. }

//这个是rtxTrack是webConfig 协议的name

练习 配置WCF服务的更多相关文章

  1. IIS8 添加配置 WCF服务

    今天在Windows8.1 操作系统部署了半天的WCF 一直老是在报错.在这里做个记录 防止下次忘记 在网上查了半天.终于知道原来IIS8不支持WCF服务SVC的请求.所以必须要给IIS8添加WCF服 ...

  2. IIS8.5 的环境下添加配置WCF服务!!!!!

    添加步骤: 1.打开iis8.5,先部署wcf服务. 2.首先添加MIME类型 扩展名:“.svc” MIME类型:“application/octet-stream” 3.添加 处理程序映射 请求路 ...

  3. 在配置WCF服务的时候出现的错误总结

    1.由于扩展配置问题而无法提供您请求的页面.如果该页面是脚本,请添加处理程序.如果应下载文件,请添加 MIME 映射. 我是通过安装图中的FramWork3.5.1搞定的. 网上的其他参考: http ...

  4. WCF系列教程之WCF服务配置工具

    本文参考自http://www.cnblogs.com/wangweimutou/p/4367905.html Visual studio 针对服务配置提供了一个可视化的配置界面(Microsoft ...

  5. WCF服务二:创建一个简单的WCF服务程序

    在本例中,我们将实现一个简单的计算服务,提供基本的加.减.乘.除运算,通过客户端和服务端运行在同一台机器上的不同进程实现. 一.新建WCF服务 1.新建一个空白解决方案,解决方案名称为"WC ...

  6. Wcf for wp8 创建wcf服务 连接wp8模拟器并显示来自wcf服务的接口信息 (一)

    下载: vs2012 pro for wp8 iis express http://download.microsoft.com/download/B/2/8/B2801FEE-9A60-4AFA-8 ...

  7. WCF学习系列一_创建第一个WCF服务

    原创作者:灰灰虫的家http://hi.baidu.com/grayworm WCF开发实战系列一:创建第一个WCF服务 在这个实战中我们将使用DataContract,ServiceContract ...

  8. WCF开发实战系列一:创建第一个WCF服务

    WCF开发实战系列一:创建第一个WCF服务 (原创:灰灰虫的家http://hi.baidu.com/grayworm) 在这个实战中我们将使用DataContract,ServiceContract ...

  9. WCF开发实战系列一:创建第一个WCF服务 转

    转 http://www.cnblogs.com/poissonnotes/archive/2010/08/28/1811064.html 在这个实战中我们将使用DataContract,Servic ...

随机推荐

  1. JavaScript中数组的排序方法:1.冒泡排序 2.选择排序

      //1.选择排序: //从小到大排序:通过比较首先选出最小的数放在第一个位置上,然后在其余的数中选出次小数放在第二个位置上,依此类推,直到所有的数成为有序序列. var arr2=[19, 8, ...

  2. Oracle使用——Linux系统下使用命令实现oracle数据库数据导入

    背景 在工作当中,数据库的备份及数据导入是必不可少的操作,在完全无界面的Linux操作系统中,我们应该怎样实现oracle数据库的导入呢 前提 服务器已配置ftp 模拟环境 一台linux应用服务器上 ...

  3. repo回退当前分支下所有仓库到指定日期前的最新代码版本【转】

    本文转载自:https://blog.csdn.net/u011006622/article/details/70272087 执行下面这样的repo命令就行了:  repo forall -c 'c ...

  4. upc组队赛1 过分的谜题【找规律】

    过分的谜题 题目描述 2060年是云南中医学院的百年校庆,于是学生会的同学们搞了一个连续猜谜活动:共有10个谜题,现在告诉所有人第一个谜题,每个谜题的答案就是下一个谜题的线索....成功破解最后一个谜 ...

  5. P2053 [SCOI2007]修车

    思路 很妙的网络流题目 最开始我简单的想直接把n个车的点和m个人员的点直接用cap=t(i,j)的边连起来,显然是假的,因为没有考虑到车主等待的时间长度 然后考虑分析将\(w_1,w_2,\dots, ...

  6. 【论文笔记】Learning Convolutional Neural Networks for Graphs

    Learning Convolutional Neural Networks for Graphs 2018-01-17  21:41:57 [Introduction] 这篇 paper 是发表在 ...

  7. (zhuan) Where can I start with Deep Learning?

    Where can I start with Deep Learning? By Rotek Song, Deep Reinforcement Learning/Robotics/Computer V ...

  8. [LightOJ 1341] Aladdin and the Flying Carpet (算数基本定理(唯一分解定理))

    题目链接: https://vjudge.net/problem/LightOJ-1341 题目描述: 问有几种边长为整数的矩形面积等于a,且矩形的短边不小于b 算数基本定理的知识点:https:// ...

  9. Unity3D学习笔记(二十七):MVC框架下的背包系统(2)

    Tools FileTools using System.Collections; using System.Collections.Generic; using UnityEngine; using ...

  10. 增强 用文本增强修改SAP标准屏幕中的字段名称 属于元素的文本增强

    如果想要改变标准屏幕中的字段名称,如把物料主数据基本数据元素的名字改为我们想要的名字 . 1.首先,事务MM03进入物料主数据的基本数据2视图中,将鼠标光标放在需要更改的字段“页格式”上,然后按F1键 ...