Regan-Hmily-Du 2019-10-24 19:26 采纳率: 0%
浏览 473
已结题

WCF生成的WSDL内容,能否自定义binding的name属性

各位大佬,小白请教个问题。。
WCF,生成的wsdl文件,我想自定义下图两个红框中的名字,有办法吗?因为不方便写配置,因此我使用的代码的方式,代码如下:

[ServiceContract(Namespace = "http://ws.substation.com/", Name = "SubstationPlatform"
        , ConfigurationName = "SubstationServiceLib.SubstationPlatform")]
    public interface IDispatchService
        {
            ...
        }

        [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single
        , Namespace = "ws.substation.com", Name = "SubstationPlatformImplService"
        , ConfigurationName = "SubstationServiceLib.SubstationPlatformService")]
    public class DispatchService : IDispatchService
        {
            ...
        }
DispatchService service = new DispatchService(this);
                this._host = new ServiceHost(service, new Uri(this.clientLocalAddr));
                this._host.AddServiceEndpoint(typeof(IDispatchService), new BasicHttpBinding(), new Uri(this.clientLocalAddr));

                ServiceMetadataBehavior metadataBehavior = this._host.Description.Behaviors.Find<ServiceMetadataBehavior>();
                if (metadataBehavior == null)
                {
                    metadataBehavior = new ServiceMetadataBehavior();
                    this._host.Description.Behaviors.Add(metadataBehavior);
                }
                metadataBehavior.HttpGetEnabled = true;
                Binding binding = MetadataExchangeBindings.CreateMexHttpBinding();
                this._host.AddServiceEndpoint(typeof(IMetadataExchange), binding, "mex");

主要是想把自动生成的后缀_SubstationPlatform给去掉,请问有没有方法可以实现呢?谢谢各位大佬了~
图片说明

  • 写回答

2条回答 默认 最新

  • threenewbee 2019-10-24 22:39
    关注

    在配置文件里面,找,有

    <binding name="binding名">
    

    修改为你要的

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容