.HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WCFTool.aspx.cs" Inherits="HraWeb.工具页面.WCFTool" %> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<label>请输入接口(包含程序集):</label> <asp:TextBox ID="txt_Interface_" runat="server" Width=""></asp:TextBox>
<br />
<label>请输入类(包含程序集):</label>
<asp:TextBox ID="txt_Class_" runat="server" Width=""></asp:TextBox> <br />
<label>请输入ip:</label>
<br />
<asp:TextBox ID="txt_Ip_" runat="server"></asp:TextBox> <label>请输入端口:</label>
<asp:TextBox ID="txt_Port_" runat="server"></asp:TextBox> <br />
<asp:Button ID="Button1" runat="server" Text="生成wcf配置" OnClick="Button1_Click" />
<br /> <label>WCFEndPointProxy:</label>
<br />
<asp:TextBox ID="txt_WCFEndPointProxy_" runat="server" TextMode="MultiLine" Height="" Width=""></asp:TextBox>
<p></p>
<label>ClientEndPoint:</label>
<p></p>
<asp:TextBox ID="txt_ClientEndPoint_" runat="server" TextMode="MultiLine" Width="" Height="" ></asp:TextBox>
<p></p>
<label>BLL.xml</label>
<br />
<asp:TextBox ID="txt_BLL_" runat="server" TextMode="MultiLine" Height="" Width=""></asp:TextBox>
<p></p>
<label>ServiceEndPoint:</label>
<p></p>
<asp:TextBox ID="txt_ServiceEndPoint_" runat="server" TextMode="MultiLine" Height="" Width=""></asp:TextBox>
<p></p>
<label>SVC:</label>
<br />
<asp:TextBox ID="txt_SVC_" runat="server" TextMode="MultiLine" Width="" Height=""></asp:TextBox>
<br />
<label>proxyclass:</label>
<br />
<asp:TextBox ID="txt_ProxyClass_" runat="server" TextMode="MultiLine" Width="" Height=""></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Width="" Height="" ></asp:TextBox>
</div>
</form>
</body>
</html> ..CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; namespace HraWeb.工具页面
{
public partial class WCFTool : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void Button1_Click(object sender, EventArgs e)
{ string ip = txt_Ip_.Text.Trim();
string port = txt_Port_.Text.Trim();
string FullName = txt_Class_.Text.Split(',')[].Trim();
string className = FullName.Split('.')[FullName.Split('.').Length - ].Trim();
string classAssembly = txt_Class_.Text.Split(',')[].Trim();
string interfaceName = txt_Interface_.Text.Split(',')[].Trim();
string iterfaceClassName = interfaceName.Split('.')[interfaceName.Split('.').Length - ];
string interfaceAssembly = txt_Interface_.Text.Split(',')[].Trim();
txt_WCFEndPointProxy_.Text = $@"
<object id=""{className}Proxy_{ip}_{port}"" type = ""{interfaceName},{interfaceAssembly}""
factory-object = ""{className}ChannelFactory_{ip}_{port}""
factory-method = ""CreateChannel"" singleton =""false""/>
<!--工厂-->
<object id = ""{className}ChannelFactory_{ip}_{port}""
type = ""System.ServiceModel.ChannelFactory&lt;{interfaceName}>, System.ServiceModel"">
<constructor-arg name = ""endpointConfigurationName"" value = ""{className}_IContract_{ip}_{port}""/>
</object>"; txt_ClientEndPoint_.Text = $@"
<endpoint address = ""http://{txt_Ip_.Text.Trim()}:{txt_Port_.Text.Trim()}/SVC/{className}.svc""
binding = ""wsHttpBinding""
bindingConfiguration = ""bindCfg_http""
contract = ""{interfaceName}""
name = ""{className}_IContract_{ip}_{port}""/>"; txt_BLL_.Text = $@"<object id = ""{className}"" type = ""{FullName}, {classAssembly}"" >
< property name = ""Dao"" ref= ""CommonService"" />
</object>"; txt_ServiceEndPoint_.Text = $@"
<service name=""{className}"" behaviorConfiguration = ""ServiceBehavior_DIC"">
<endpoint address = """" contract = ""{interfaceName}"" binding = ""wsHttpBinding"" bindingConfiguration = ""bindCfg_http""/>
</service>"; txt_SVC_.Text = $@"<%@ ServiceHost Language =""C#"" Debug = ""true"" Service = ""{className}"" Factory = ""Spring.ServiceModel.Activation.ServiceHostFactory""%>"; txt_ProxyClass_.Text = $@"public class {className}Proxy :
ServiceProxyBase<{iterfaceClassName}>
{{
public override string ServieName
{{
get
{{
return ""{className}"";
}}
}} }}"; TextBox2.Text = $@" 服务类请加上:[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
接口契约请加上[ServiceContract]
接口方法[OperationContract];
";
}
}
}

WCF TOOL CODE的更多相关文章

  1. 使用 EF Power Tool Code Frist 生成 Mysql 实体

    原文:使用 EF Power Tool Code Frist 生成 Mysql 实体 1,在要生成的项目上右键   2,   3,   4,   5,  生成后的效果     已知问题: 1,在Mys ...

  2. WS+MQ+WCF+EF(Code First)

    前言 有段时间没有更新博文了,一直在忙工作很少有时间静下心来继续研究点东西,说来也惭愧,归咎原因最主要的还是因为懒惰.空想也是不管用的,有时候很多想法被扼杀到了摇篮里,还没开始做就放弃了,这是多数人会 ...

  3. 15个最佳的代码评审(Code Review)工具

    代码评审可以被看作是计算机源代码的测试,它的目的是查找和修复引入到开发阶段的应用程序的错误,提高软件的整体素质和开发者的技能.代码审查程序以各种形式,如结对编程,代码抽查等.在这个列表中,我们编制了1 ...

  4. WCF vs ASMX WebService

    This question comes up a lot in conversations I have with developers. “Why would I want to switch to ...

  5. 17款code review工具

    本文是码农网原创翻译,转载请看清文末的转载要求,谢谢合作! 好的代码审查器可以大大地帮助程序员提高代码质量,减少错误几率. 虽然现在市场上有许多可用的代码审查工具,但如何挑选也是一个艰巨的任务.在咨询 ...

  6. MSCRM 通过Ajax调用WCF服务

    Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...

  7. 项目管理系列--好用的代码评审(Code Review)工具

    1. Gerrit Gerrit is a web based code review system, facilitating online code reviews for projects us ...

  8. how to do error handing with WCF by using attributes to log your errors z

    There are multiple ways to do error handling in WCF as listed by Pedram Rezaei Blog. The default way ...

  9. VS Code开发技巧集锦【转】

    转自:http://blog.csdn.net/tiantangyouzui/article/details/52163175 入门 自定义 扩展 文件/文件夹管理 编辑技巧 智能感应功能 代码片段 ...

随机推荐

  1. diffutils's diff

    比较文件的差异 diff,用来查看两个文件的差异之处,或者两个目录之中的对应文件.倘若比较的不是文本文件,而是二进制文件,只会报告两者不同.输出文本文件的异同时,可以按照多个格式输出,根据使用的选项决 ...

  2. 本地yum源快速创建

    1.建立挂载目录mkdir /rui 2.挂载iso到新建的/rui目录

  3. js选择器 querySelector

    <form method="post" action="" id="myform"> <input type=" ...

  4. OpenCL 存储器次序的验证

    ▶ <OpenCL异构并行编程实战>P224 的代码,先放上来,坐等新设备到了再执行 //kernel.cl __global ); // 全局原子对象 __kernel void mem ...

  5. 61. oracle给用户解锁

    1.查看用户状态select username,account_status from dba_users where username='test'; 2.解锁: ALTER USER YS_ADM ...

  6. HTML5 Canvas ( 文字的度量 ) measureText

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. 主流JS库一览

    主流JS库一览 标签: prototypedojomootoolsprototypejsjqueryjavascript 2009-10-14 22:52 19936人阅读 评论(2) 收藏 举报   ...

  8. 一个js程序:离下一个圣诞节还有多少天?

    话不多说上代码: //离下一个圣诞节还有多少天 var christ=new Date(); christ.setMonth(11); christ.setDate(25); var year=now ...

  9. iOS Hardware Guide

    来自U3D文档 Hardware models The following list summarizes iOS hardware available in devices of various g ...

  10. Haskell语言学习笔记(29)CPS

    CPS (Continuation Passing Style) CPS(延续传递风格)是指函数不把处理结果作为返回值返回而是把处理结果传递给下一个函数的编码风格. 与此相对,函数把处理结果作为返回值 ...