WCF TOOL CODE
.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<{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的更多相关文章
- 使用 EF Power Tool Code Frist 生成 Mysql 实体
原文:使用 EF Power Tool Code Frist 生成 Mysql 实体 1,在要生成的项目上右键 2, 3, 4, 5, 生成后的效果 已知问题: 1,在Mys ...
- WS+MQ+WCF+EF(Code First)
前言 有段时间没有更新博文了,一直在忙工作很少有时间静下心来继续研究点东西,说来也惭愧,归咎原因最主要的还是因为懒惰.空想也是不管用的,有时候很多想法被扼杀到了摇篮里,还没开始做就放弃了,这是多数人会 ...
- 15个最佳的代码评审(Code Review)工具
代码评审可以被看作是计算机源代码的测试,它的目的是查找和修复引入到开发阶段的应用程序的错误,提高软件的整体素质和开发者的技能.代码审查程序以各种形式,如结对编程,代码抽查等.在这个列表中,我们编制了1 ...
- WCF vs ASMX WebService
This question comes up a lot in conversations I have with developers. “Why would I want to switch to ...
- 17款code review工具
本文是码农网原创翻译,转载请看清文末的转载要求,谢谢合作! 好的代码审查器可以大大地帮助程序员提高代码质量,减少错误几率. 虽然现在市场上有许多可用的代码审查工具,但如何挑选也是一个艰巨的任务.在咨询 ...
- MSCRM 通过Ajax调用WCF服务
Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...
- 项目管理系列--好用的代码评审(Code Review)工具
1. Gerrit Gerrit is a web based code review system, facilitating online code reviews for projects us ...
- 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 ...
- VS Code开发技巧集锦【转】
转自:http://blog.csdn.net/tiantangyouzui/article/details/52163175 入门 自定义 扩展 文件/文件夹管理 编辑技巧 智能感应功能 代码片段 ...
随机推荐
- uva146-枚举,排列
题意: 输入最多150个小写字母,在字典序增大的方向,求下一个排列是什么. 模拟枚举,最后一个字符是递归的最后一层(n层),那么把它弹出栈(还剩n-1层),如果n-1层的字符比第n层小,说明把n层的字 ...
- UVA699-落叶-二叉树
1:用一根数轴,根结点是坐标index,左结点-1,右结点+1 还有一个0ms的不知道怎么过的 #include<stdio.h> #include<iostream> #in ...
- Vue2.0中v-for迭代语法变化(key、index)
语法发生了变化:http://blog.csdn.net/sinat_35512245/article/details/53966788 新数组语法 value in arr (value, inde ...
- ActiveMQ无法启动
解决办法:activemq无法启动,端口被占用 用netstat -an无法查出61616被哪个进程占用(实践证明,netstat -ano|findstr '61616'什么也没有找到) 经过排查和 ...
- python 2 类与对象
1.类与对象的概念 类即类别.种类,是面向对象设计最重要的概念,从一小节我们得知对象是特征与技能的结合体,而类则是一系列对象相似的特征与技能的结合体. 那么问题来了,先有的一个个具体存在的对象(比如一 ...
- c++11新特性总结(转)
1.类型与变量相关 1.1.nullptr: 取代了NULL,专用于空指针 1.2.constexpr: 近似const, 可以修饰变量,也可以修饰函数, 修饰变量如: const int globa ...
- 一个简单例子弄懂什么是javascript函数劫持
javascript函数劫持很简单,一般情况下,只要在目标函数触发之前,重写这个函数即可. 比如,劫持eval函数的代码如下: var _eval=eval; eval=function(x){ if ...
- SecureCRT去除关闭Session的确认窗口提示
- Haskell语言学习笔记(49)ByteString Text
Data.ByteString String 是 [Char] 的同义词,在使用上存在List的惰性所带来的性能问题. 在处理大型二进制文件时,可以使用 ByteString 来代替 String. ...
- spark性能调优 数据倾斜 内存不足 oom解决办法
[重要] Spark性能调优——扩展篇 : http://blog.csdn.net/zdy0_2004/article/details/51705043