【问题标题】:How to completely change tempuri.org namespace in WCF 4.5如何在 WCF 4.5 中完全更改 tempuri.org 命名空间
【发布时间】:2016-09-14 12:12:45
【问题描述】:

我想在 .NET 4.5 开发的 WCF 中更改 tempuri.org 命名空间。到目前为止,我发现的所有解决方案都解决了 4.0 版中的问题,该版本在 web.config 中包含“服务”标签。在 4.5 的情况下,没有“服务”标签,所以我无法更改绑定命名空间。

我找到了这个页面:http://blogs.ugidotnet.org/raffaele/archive/2011/02/10/la-soluzione-definitiva-al-namespace-tempuri.org-in-wcf-4.aspx

这解释了如何以编程方式执行此操作,但我想知道是否有更简单的解决方案。

詹姆

【问题讨论】:

  • <services> 标签仍然存在于 .NET 4.5 中。从 .NET 4.0 开始,WCF 引入了简化配置的概念,这使得 <services> 部分是可选的。不过,您仍然可以使用它。
  • <services> - 请注意页面顶部显示“.NET Framework(当前版本)”。

标签: c# .net wcf namespaces wcf-binding


【解决方案1】:

只需查看您的 WebServiceName.asmx.cs 文件并将 http://tempuri.org 更改为您自己的唯一字符串。

using System;
using System.Linq;
using System.Web.Services;

namespace WCFWebService
{
    [WebService(Namespace = "http://tempuri.org")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class WebServiceName : System.Web.Services.WebService
    {

        [WebMethod]

【讨论】:

    猜你喜欢
    • 2011-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    相关资源
    最近更新 更多