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 入门 自定义 扩展 文件/文件夹管理 编辑技巧 智能感应功能 代码片段 ...
随机推荐
- OpenACC Hello World
▶ 在 windows 10 上搭建 OpenACC 环境,挺麻烦 ● 安装顺序:Visual Studio 2015(PGI 编译器不支持 Visual Studio 2017):CUDA Tool ...
- https Configure a Spring Boot app for HTTPS on Amazon AWS.
参考: https://geocolumbus.github.io/HTTPS-ELB-AWS-Spring-Boot/ 1. 在服务器端配置 证书 域名 映射 2. 导入依赖: <depe ...
- leetcode953
public class Solution { public bool IsAlienSorted(string[] words, string order) { string HumanDic = ...
- chrome浏览器控制台 console不打印信息问题解决办法。
转自:https://blog.csdn.net/wang17866603359/article/details/79083776 最近换了安装chrome,想按F12调试下代码,发现控制台什么信息都 ...
- 10.Action中的method属性
转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 在struts1.x中我们知道通过继承DispatchAction可以实现把 ...
- nginx 域名绑定
单个域名 upstream web{ server ;//这里绑定你要访问的服务器地址 keepalive ; } server { listen ; server_name www.xxxx.con ...
- ios 避免navigationcontroller出现时scrollview内容被resize
viewDidLoad中设置以下属性 self.automaticallyAdjustsScrollViewInsets = NO;
- 认识serviceLoader
最近在研究系统设计方面的东西,发现有很多通用的解决方案,包括spring配置扩展以及serviceLoader的应用,这里简单记录下serviceLoader的简单应用,网上例子很多,大同小异,本人觉 ...
- JAVA学习(七)__Spring的@Autowired注入规则
@Autowired 默认是按照byType进行注入的,但是当byType方式找到了多个符合的bean,又是怎么处理的? 经过一些代码的测试,我发现,Autowired默认先按byType,如果发现找 ...
- ML_入门
N-gram 输入法后来提醒nlp自然语言理解一个向量映射到另一个空间,为什么是向量呢?模型其实是向量,一张图片表示成向量,像素表示成rgb ,每一个维度 数的度文本变成向量 one-hot repr ...