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 入门 自定义 扩展 文件/文件夹管理 编辑技巧 智能感应功能 代码片段 ...
随机推荐
- shell中使用函数
函数定义.调用 $ cat te.sh #!/bin/bash # define a function test() { echo "This is a function." } ...
- centos6.5 64安装ffmpeg过程支持转码mp3
百度了几个文章 大致知道了思路 首先yum源安装是木有的,只能编译安装了. 要安装ffmpeg要先安装一个yasm支持汇编优化(FFmpeg需要) 在安装一个lame,支持mp3的转码 那就是需要3步 ...
- zabbixzabbix
一,安装文档 https://www.zabbix.com/documentation/4.0/zh/manual/installation/requirements zabbix3.2.6安装 ...
- Java对字符串使用MD5进行加密(亲测有效)
转自:https://blog.csdn.net/jay314159/article/details/4918358 前言: MD5即Message-Digest Algorithm 5(信息-摘要算 ...
- mysql case, if
if语句: 用法和excel的if函数很像 if(expr1, value_if_expr1_is_true, value_if_expr1_is_false) select if(tag = 3, ...
- Java LinkedList的实现原理
LinkedList是Java List类型的集合类的一种实现,此外,LinkedList还实现了Deque接口.本文基于Java1.8,对于LinkedList的实现原理做一下详细讲解. (Java ...
- 判断一个对象是否为真 __nonzero__ 方法和 __len__方法
class A(): def __nonzero__(self): # 判断 一个对象是否为空,先查看该方法的返回值 return 1 def __len__(self): # 如果没有上一个方法,那 ...
- MIUI 6的毛玻璃效果的技术实现(实时模糊)
说说MIUI 6的毛玻璃效果的技术实现. 很久以前我们的文件夹打开和最近任务等几个地方就使用了毛玻璃效果,在技术上讲就是背景模糊.应该是比iOS 7的使用要早很多.不过那时候我们使用的是先对背景截 ...
- DBA 招聘
数据库管理员(资深) 眼控科技 10-19万 72小时反馈 上海 6小时前 大专及以上 2年以上经验 普通话 25-35岁 绩效奖金 带薪年假 午餐补助 定期体检 年底双薪 五险一金 职位描述: 工作 ...
- Containerpilot 配置文件 之 Telemetry
如果提供telemetry选项,ContainerPilot将公开可用于刮擦性能telemetry的Prometheus HTTP客户端界面. telemetry接口被公告为consul服务. tel ...