.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. python3解析XML文件

    软硬件环境 Ubuntu 15.10 32bit Python 3.5.1 PyQt 5.5.1 前言 Python解析XML的方法挺多,本文主要是利用ElementTree来完成. 实例讲解 解析X ...

  2. leetcode961

    class Solution: def repeatedNTimes(self, A): doubleN = len(A) N = doubleN / 2 dic = {} for a in A: i ...

  3. Dictionary 字典的使用

    Dim a, d, i             '创建几个变量Set d = CreateObject("Scripting.Dictionary")d.Add "a&q ...

  4. visual c++ 中的stdafx.h头文件的作用

    stdafx.h VC工程里面经常见到stdafx.h这个头文件,以前也没有特别注意,但是这个文件用不好经常会出错,所以就GOOGLE了一下,总算是弄清楚了... stdafx的英文全称为:Stand ...

  5. 设计模式学习笔记(1)Iterator

    Iterator 模式 public interface Iterator { public boolean hasNext(); public Object next(); } public int ...

  6. Unity C# 调用 C++ DLL 并在 DLL 中调用 C# 的回调函数

    Unity C# 调用 C++ DLL 并在 DLL 中调用 C# 的回调函数~~~    呵呵... 看着有点晕.. 再解释一下就是 在Unity中 使用 C# 调用 C++ 写的 DLL, 但是在 ...

  7. jremoting的功能扩展点

    1  InvokeFilter,实现此接口 可以在consumer端 与provider端的调用过程中拦截住请求调用. 已经实现的InvokeFilter包括 RetryInvokeFilter:实现 ...

  8. go语言channel的别样用法

    1.返回值使用通道 func main() { // 生成随机数作为一个服务 randService := randGenerator() // 从服务中读取随机数并打印 fmt.Printf(&qu ...

  9. keras、 tensor flow 教程

    [keras]http://keras-cn.readthedocs.io/en/latest/getting_started/concepts/,[tensorflow] http://blog.c ...

  10. python格式化输出(转)

    在许多编程语言中都包含有格式化字符串的功能,比如C和Fortran语言中的格式化输入输出.Python中内置有对字符串进行格式化的操作%. 模板 格式化字符串时,Python使用一个字符串作为模板.模 ...