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 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常